Javascript examples for jQuery:Mouse Event
Jquery on click for any element with class
<html lang="en"> <body translate="no"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function(){ $("#element").click(function(){ if($(this).hasClass("hide")){ $(this).slideUp(200);/* ww w. j a va2s . com*/ } }); }); </script> <button id="element" class="hide">Element 1</button> <button id="element" class="show">Element 2</button> </body> </html>