How Do I Iterate Over The Results Of A Jquery Selector?
When I'm trying to store all elements as objects in array (using $('a')), and then get the position of each of them, it doesn't work. years = $('a'); for(i=0;i< years
Solution 1:
Use this instead:
$("a").each(function() {
var pos = $(this).position();
if (pos.top > year.position().top) {
// hurray
}
});
Also what is the value of year
? I prefer to name jQuery objects like this: var $year = $("#year");
The $
helps you remember it's a jQuery object.
Post a Comment for "How Do I Iterate Over The Results Of A Jquery Selector?"