[英]What am i doing wrong with my jQuery if/else statement?
我知道我的html很好,但是如何使它成为if if语句。 我希望文本消失,按钮的文本更改,然后再次按下按钮以使其反向。
这是我的代码:
$("#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"){
试试这个js小提琴
$(document).ready(function(){
$("#disappearingButton").click(function(){
$('#btheParaook').toggle(function(){
$('#disappearingButton').text('click to appear');
} );
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.