Amir Ebrahimi Amir Ebrahimi -4 years ago 166
jQuery Question

No reverse in toggle jquery

The following code, shows a div when you click on the button.

But when you, click again, it toggle the div.

I dont need this reverse. I just wanna when you click on the button, it shows the hidden div. and after that, the button doesn't work.

How can I do it?



(function ($) {
$(document).ready(function() {
$("#thisclick").click(function () {
$("#example").slideToggle("slow");
});
});
})(jQuery);

h3 {
display:none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<button id="thisclick" >Click</button>
<h3 id="example">Example Div</h3>




Answer Source

Use slideDown to get the effect you want.

slideDown is 1 part of slideToggle. The second part is slideUp

(function($) {
  $(document).ready(function() {
    $("#thisclick").click(function() {
      $("#example").slideDown("slow");
    });
  });
})(jQuery);
h3 {
  display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<button id="thisclick">Click</button>
<h3 id="example">Example Div</h3>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download