Jquery toggle to change the any html element text here is logic i am putting to change the button text while toggling
You can use text method:
html
<button class='pushme'>PUSH ME</button>
Jquery
$(function(){
$(".pushme").click(function () {
$(this).text(function(i, text){
return text === "PUSH ME" ? "DON'T PUSH ME" : "PUSH ME";
})
});
})
Example 2:
$(".pushme").click(function() {
if ($(this).text() == "PUSH ME") {
$(this).text("DON'T PUSH ME");
} else {
$(this).text("PUSH ME");
};
});
I hope there examples will help you..