确定元素是否是其父元素的最后一个子元素


70

使用jQuery,有没有一种快速的方法来知道某个元素是否是其父元素的最后一个孩子?

例:

<ul>
  <li id="a"></li>
  <li id="b"></li>
  <li id="c"></li>
</ul>

$('#b').isLastChild(); //should return FALSE
$('#c').isLastChild(); //should return TRUE

Answers:




By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.