I know my html is fine, but how do i make this an if else statement. I want the text to disappear and the text of the button to change, and then reverse by pressing the button again.
Here is my code:
$("#disappearingButton").click(function(){
if($("#thePara").is(":hidden")){
$("#thePara").show();
$("#disappearingButton").html("Click to disappear");
}else{
$("#thePara").hide();
$("#disappearingButton").html("Click to reappear");
}
});
if(!$("#thePara").is(":visible")){
要么
if ($("#thePara").css("display") == "none"){
try this js fiddle
$(document).ready(function(){
$("#disappearingButton").click(function(){
$('#btheParaook').toggle(function(){
$('#disappearingButton').text('click to appear');
} );
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.