简体   繁体   中英

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> 

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> 

Replace slideToggle with slideDown .

slideToggle combines both slideDown and slideUp depending on your current state.

代替“ slideToggle”,使用“ slideDown”,它将使其工作。

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