jquery toggle text on click code example
Example 1: toggle text jquery
$("button").click(function(){
$(this).text($(this).text() == 'Show' ? 'Close' : 'Show');
});
Example 2: jquery toggle text on click
$(function(){
$(".pushme").click(function () {
$(this).text(function(i, text){
return text === "PUSH ME" ? "DON'T PUSH ME" : "PUSH ME";
})
});
})
Example 3: javascript when button clicked different text appears
function show() {
var box = document.getElementById('box');
var displaySetting = myClock.style.display;
var showButton = document.getElementById('showButton');
if (displaySetting == 'block') {
myClock.style.display = 'none';
clockButton.innerHTML = 'Show box';
}
else {
myClock.style.display = 'block';
clockButton.innerHTML = 'Hide box';
}
}
Example 4: how to toggle in text add
$(".email-slide").click(function(){
$("#panel").slideToggle("slow");
$(this)
.text("Close")
.toggleClass("active");
});