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() {
    // get the box
    var box = document.getElementById('box');

    // get the current value of the box's display property
    var displaySetting = myClock.style.display;

    // also get the box button, so we can change what it says
    var showButton = document.getElementById('showButton');

    // now toggle the box and the button text, depending on current state
    if (displaySetting == 'block') {
      // box is visible. hide it
      myClock.style.display = 'none';
      // change button text
      clockButton.innerHTML = 'Show box';
    }
    else {
      // box is hidden. show it
      myClock.style.display = 'block';
      // change button text
      clockButton.innerHTML = 'Hide box';
    }
  }

Example 4: how to toggle in text add

$(".email-slide").click(function(){
    $("#panel").slideToggle("slow");
    $(this)
    .text("Close")
    .toggleClass("active");
});