I would like to update the following:
<a data-fb="4dfsdgdsgsdfgsdfgcf08" class="fb-like" href="#">
<span class="like-icon">Likes:</span> 10</a>
I wish to update the value ’10’ with a result returned from a web service, I have the result stored in a variable called fbNumber. The data-fb attribute is unique so I wish to search for this and update the value.
A simple
.replaceseems to be sufficient here. You can get the current contents using the.htmlmethod, and replace any sequence of numbers found within with your new number:Fiddle: http://jsfiddle.net/GbqJg/