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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -