I’m trying to figure out the jQuery statement to rename “apple” with “orange:”
<a id="alvin" href="http://www.camille.com"><ins class="xxx">Anna</ins>apple</a>
Can this be done easily?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I removed the
#from the ID, since it is not a valid ID character.Given that, try this:
Live Example: http://jsfiddle.net/u49wy/
.contents()returns all the child nodes of the element, including text nodes.The code then grabs the last
elementnode (which is a text node) and updates itsnodeValue, which is how you update the value of a text node..contents()– http://api.jquery.com/contents