jquery toggle text on click
$("button").click(function(){
$(this).text($(this).text() == 'Show' ? 'Close' : 'Show');
});
4
2
$(function(){
$(".pushme").click(function () {
$(this).text(function(i, text){
return text === "PUSH ME" ? "DON'T PUSH ME" : "PUSH ME";
})
});
})
Thank you!
2
0
4.4
5
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';
}
}
Thank you!
5
0
4
2
$(".email-slide").click(function(){
$("#panel").slideToggle("slow");
$(this)
.text("Close")
.toggleClass("active");
});
Thank you!
2
0
Are there any code examples left?
New code examples in category Javascript
-
Javascript 2023-04-21 22:52:36
-
Javascript 2022-03-27 22:25:20 javascript download string as file
-
Javascript 2022-03-27 21:40:22 sort numbers in array javascript
-
Javascript 2022-03-27 21:20:04 compare two arrays and return the difference javascript
-
Javascript 2022-03-27 21:15:02 javascript regex french phone number
-
Javascript 2022-03-27 21:05:03 cypress custom error message
-
Javascript 2022-03-27 21:00:05 create element javascript with id
-
Javascript 2022-03-27 20:40:57 feather icons react
-
Javascript 2022-03-27 20:20:01 how to make graphql request in axios
-
Javascript 2022-03-27 20:15:07 bootstrap validator password and confirm password