javascript - jQuery is(":first") takes no effect -
i use jquery is(":first") judge whether element first in siblings, return false. there wrong? or bug of jquery? thx.
$(".page:first").is(":first"); //always return false.
to test whether first found .page element first sibling can use .index():
if ($('.page:first').index() == 0) { // it's first child } or simply:
if ($('.page').index() == 0) { // it's first child } the .is() function works matching current result set against given selector, first element of document, i.e. <html>. $('html').is(':first') true.
Comments
Post a Comment