2014-02-17 29 views
0
$(document).ready(function(){ 
    var $p = $('div.striker'); 

    $("#show").click(function(){ 
    $p.css('overflow', 'visible'); 

    }); 
}); 

如何关闭点击按钮???如何在点击时关闭显示按钮?

HTML

<div class="striker"> 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 
      If you click on the "Hide" button, I will disappear. 

      </div> 
<button id="show">Show</button> 
+1

你是什么意思关闭?你的意思是隐藏吗? –

+0

使用css属性“显示:无”来隐藏.. –

回答

0

,如果你想隐藏点击这个节目按钮使用:

$(document).ready(function(){ 
     var $p = $('div.striker'); 

     $("#show").click(function(){ 
     $p.hide(); 

     }); 
    }); 

现场演示:http://jsfiddle.net/qsDn5/31/

如果你想切换显示在显示时,点击按钮。

试试这个:

$(document).ready(function(){ 
    var $p = $('div.striker'); 

    $("#show").click(function(){ 
    $p.toggle(); 

    }); 
}); 

如果显示前锋内容将隐藏,如果它隐藏它会显示前锋内容。

现场演示:http://jsfiddle.net/qsDn5/32/

0

而不是

`$p.css('overflow', 'visible');` 

尝试:

$p.css('display', 'none'); 
1

更改JS来:

$(document).ready(function(){ 
    var $p = $('div.striker'); 

    $("#show").click(function(){ 
    $p.css('display', 'none'); 
    // or $p.hide(); 

    }); 
}); 
0

对于隐藏显示按钮

$("#show").click(function(){ 
    $p.css('overflow', 'visible'); 
    $(this).hide(); // or $(this).css('display','none'); 
    }); 
0

您可以使用任何的这两个选项:

$p.css('visibility', 'hidden');` 

这将隐藏按钮,但使用的空间仍然使用。

$p.css('display', 'none'); 

这将隐藏按钮,并且按钮先前出现的空间也被释放。

space - 显示按钮的区域。

相关问题