I'm trying to select all the bullets except the last bullet but I am doing something incorrectly.
Here is my html
<ul> <li>Text</li> <li>Text</li> <li>Text</li> <li>Text</li> <li>Text</li> </ul> <ul> <li>Text</li> <li>Text</li> <li>Text</li> <li>Text</li> <li>Text</li> </ul> <ul> <li>Text</li> <li>Text</li> <li>Text</li> <li>Text</li> <li>Text</li> </ul>
And my jQuery:
jQuery('ul li:not(:last)').append(" | ");
It's adding the pipe to every bullet however...
Using the $('td:last') selector just selects the last td tag, i.e., c4.
Given a list of elements and the task is to not select a particular class using JQuery. jQuery :not() Selector: This selector selects all elements except the specified element. Parameters: It contains single parameter selector which is required.
ID and Element selector are the fastest selectors in jQuery.
Because your html contains multiple unordered lists, $('ul li')
will selects every single <li>
, in all of the <ul>
s. :last
then selects the final element in that list. Use :last-child
, which gets the last <li>
in each of the <ul>
s.
$('ul li:not(:last-child)').append(' | ');
http://jsfiddle.net/mattball/qmVdb/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With