简体   繁体   中英

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

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

$(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/

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/

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.

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.

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