I need to change the text within a link on click from ‘open’ to ‘close’.
<a href="#" id="clickMe"><span class="A open"></span>open</a>
But how do I change the label after I run an AJAX function on success?
success: function(){
$("#clickMe").find("span").toggleClass("open close");
// toggle label
}
You could modify the actual TextNode contents as well by using
contents()and the right index:or the same thing in a single line:
edit
If you wanna use some other texts than the class names, you could do it like this:
example: http://jsfiddle.net/niklasvh/ULsx4/13/
example (1): http://jsfiddle.net/niklasvh/ULsx4/ & single line: http://jsfiddle.net/niklasvh/ULsx4/12/