Return the number of elements in the jQuery object.

Before jQuery 1.8, we like use .size() to get array element count. But .size() method is deprecated as of jQuery 1.8. It’s better to use .length property instead. The reason is the .length property is public, and does not have the overhead of a function call.

So if the object is string type, .length will return sting length, and if it’s array type, it will return count of array elements.

Advertisements

About qianggan

Sr. Software Engineer
This entry was posted in Computers and Internet. Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s