I want to change span element’s text with click:
$('.int-bank h2 span').text('Open List');
$('.int-bank h2').bind("click", function (e) {
$(this).next("p").toggleClass("lblock");
var spn = $(this).find("span");
spn.text('Close List');
});
But in the second click, the span’s text does not change to “Open List”. How can I do this?
Too bad there’s no
toggleText();-). You’ll have to check the value yourself:Hey, while I’m at it, why not make a
toggleText():Then simplify your code like so: