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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -