SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: jquery .size()

  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery .size()

    I am writing a plugin for a select box. I need to get the size of the options before performing an action. How can i do this?

    Sample code:
    Code:
    jQuery.fn.doSomething = function(options){
        return this.each(function(){
            var optionsSize = this.find("options").size();
            
        });
    };
    I am getting an error:

    Code:
    this.find is not a function
    var optionsSize = this.find("options").size();
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  2. #2
    SitePoint Member
    Join Date
    May 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try

    var sizeOption = $(this).find(...)



    <snip/>
    Last edited by ScallioXTX; Jun 23, 2011 at 01:36. Reason: please wait 90 days to avail of signature

  3. #3
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried this and results in 0 size.
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •