jQuery's “:last-child” selector won't respect <body> as parent on Jsbin?

后端 未结 2 1494
Happy的楠姐
Happy的楠姐 2021-01-19 14:52

I have this simple HTML :


  
    
1
2
3
4&l
2条回答
  •  北海茫月
    2021-01-19 15:06

    :last-child returs true is the very last child is of this type (div in this case).

    JSBin links scripts at the bottom of the page (before ), so :last-child can works with script element only.

    Solution is to move scripts into head section using document.ready or after .

提交回复
热议问题