jquery - Changing a character in a class -


i amend last character of string in particular class. is, change comma full-stop in list items belonging class last (li.last). example:

<li>one,</li> <li>two,</li> <li>three,</li> <li class="last">four,</li> 

change to:

<li class="last">four.</li> 

is there simple way this?

you can use .text overload takes function, useful if have many such elements:

$('li.last').text(function(i, text){         return text.replace(/,$/, '.'); }); 

example: http://jsfiddle.net/xvhkd/

note can use :last-child selector: $('li:last-child').


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -