我知道我的html是好的,但我如何使这一个if else语句。我希望文本消失,按钮的文本改变,然后通过再次按下按钮反转。
下面是我的代码: $("#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');
} );
});
});