Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 2
要素の表示・非表示を切り替える Ajax jQuery

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 47

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 47
 
トップページ >  Ajax >  要素の表示・非表示を切り替える
初版2009/08/11: 最終更新日2009/08/11
要素の表示・非表示を切り替える
目次
要素の表示・非表示を切り替える
要素の表示・非表示を切り替える

toggle()を使用すると要素の表示・非表示を切り替えることが出来ます。
toggle()が呼び出されたときに、要素が非表示状態であれば表示状態に、表示状態であれば非表示状態に切り替えます。
また、引数にslowやfast, あるいはミリ秒単位で時間を指定すると指定した速度でアニメーションしながら表示・非表示が切り替わります。

      $("#toggle").click(function(){
          $("#area1").toggle();
      });
      $("#toggle_with_animation").click(function(){
          $("#area2").toggle("slow");
      });
    
red
blue

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 111

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/ajax/async/toggle_animation/toggle_animation.html on line 111