<html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>jQuery Click</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(function() { $(document.body).click(function() { $("div").toggle(); }); }); </script> </head> <body> <h1>jQuery Mouse Click</h1> <div>クリックすると表示/非表示を切り替えます</div> </body> </html> |
$(document.body).append("append text<br>"); |
show: function() { return showHide( this, true ); }, hide: function() { return showHide( this ); }, toggle: function( state ) { if ( typeof state === "boolean" ) { return state ? this.show() : this.hide(); } return this.each(function() { if ( isHidden( this ) ) { jQuery( this ).show(); } else { jQuery( this ).hide(); } }); } |