Help with JQuery selector :not(:last)

后端 未结 1 991
再見小時候
再見小時候 2021-02-18 12:46

I\'m trying to select all the bullets except the last bullet but I am doing something incorrectly.

Here is my html

  • Text
  • &
1条回答
  •  温柔的废话
    2021-02-18 13:26

    Because your html contains multiple unordered lists, $('ul li') will selects every single

  • , in all of the
      s. :last then selects the final element in that list. Use :last-child, which gets the last
    • in each of the
        s.

        $('ul li:not(:last-child)').append(' | ');
        

        http://jsfiddle.net/mattball/qmVdb/1/

0 讨论(0)
提交回复
热议问题