简体   繁体   English

如何关闭点击显示按钮?

[英]How to close show button on click?

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

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

  });
});

How to close on click buton ??? 如何关闭点击按钮???

HTML 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>

Change js to: 将js更改为:

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

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

  });
});

Instead of 代替

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

Try: 尝试:

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

For hiding show button 用于隐藏显示按钮

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

if you want to hide on clicking on this show button use this: 如果您想在单击此显示按钮时隐藏,请使用以下命令:

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

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

      });
    });

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

If you want to switch display when clicking in the show button. 如果要在单击显示按钮时切换显示。

try this: 尝试这个:

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

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

  });
});

It will hide if it is displaying striker content and it will display striker content if its hide. 如果它显示前锋内容,它将隐藏;如果隐藏,它将显示前锋内容。

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

You can use any of these two options: 您可以使用以下两个选项之一:

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

This will hide the button but the space used is remain used. 这将隐藏按钮,但仍保留使用的空间。

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

This will hide the button and the space where the button previously appears is also released. 这将隐藏该按钮,并且先前显示该按钮的空间也将释放。

space - The region where the button is displayed. 空格-显示按钮的区域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM