简体   繁体   中英

slideToggle with bounce effect not working

Every method that I have tried to create a bounce effective when my div slides up and down does not work. Any help would be greatly appreciated!

Here's my code

 $(document).ready(function() { $('#button').click(function() { $("#div").slideToggle(); $("#div").effect('bounce', 300); }); }); 
 div#div { width: 100px; height: 100px; background: #ccc; border: 1px solid #000; position: relative; display: none; top: 30px; left: 0; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="button">click</button> <div id="div"></div> 

Thanks for any help!

https://jsfiddle.net/zs1u8b5c/

What you wrote works as intended. However, as that is not part of jQuery's main API you need to include the UI script as well.

Updated jsFiddle: https://jsfiddle.net/1gu4u8dp/

Which would be:

<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

(preferably make a local copy)

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