William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

jQuery length property

jQuery length property

The jQuery .length property counts the number of elements in the jQuery object. It does the same way JavaScript counts array length. jQuery objects aren’t the only things that can have a length property. Strings and arrays have a length property, too.

The usage:
$(element).length -> The number of elements currently matched. Generally test if the element exists, for examples:

  --> jQuery object property: <div id="divid"> exists?

  --> String length: <div id="divid" /> include contents?

The above example is useful: they are frequently used in jQuery contexts.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: