I have a little js problem and thought this wonderfull community would be able to help me!
Let's say I want to find all $('footer')
elements and I want to know if there is either 1 or 2 footers on the page.
How would I do that?
using length() or s开发者_如何学编程omething similar?
Thanks a lot for your help :)
Use the length
[docs] property.
$('footer').length;
Please see the jQuery docs.
They're really very good, and typing length
into the search field would dynamically bring the solution to you.
Or use the .size() function - see jquery docs
$('footer').size();
You can of course just use:
document.getElementsByTagName('footer').length;
But footer is an HTML5 element, many browsers in use do not support it yet.
精彩评论