實(shí)例講解Jquery中隱藏hide、顯示show、切換toggle的用法

字號(hào):


    這篇文章主要介紹了實(shí)例講解Jquery中隱藏hide、顯示show、切換toggle的用法,感興趣的小伙伴們可以參考一下
    本文實(shí)例為大家分享了jquery中show()、hide()和toggle()用法實(shí)例,供大家參考,具體內(nèi)容如下:
    <html>
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <title>初識(shí)jQuery</title> 
    <script src="http:/www.jb51.net/jquery/1.9.0/jquery.js" type="text/javascript"></script> 
    <!--引用這個(gè)jquery庫(kù)-->
    <style> 
    #test{ 
      display:none; 
      width:120px; 
      height:50px; 
      border:1px solid blue; 
       } 
    </style> 
    </head> 
      <body> 
        <div id="test">Hello world!</div> 
        <!--設(shè)置三個(gè)按鈕,每次點(diǎn)擊調(diào)用特定的函數(shù)-->
        <button onclick="sayHello()">點(diǎn)我打開!</button> 
        <button onclick="sayGoodbye()">點(diǎn)我關(guān)閉!</button> 
        <button onclick="change()">點(diǎn)我切換!</button> 
        <script type="text/javascript"> 
          function sayHello(){ 
            $("#test").show(5000); 
          <!--設(shè)參數(shù)5000,表示用5000ms的時(shí)間完成這個(gè)動(dòng)作--> 
          } 
           function sayGoodbye(){ 
            $("#test").hide(); 
          <!--不設(shè)置,默認(rèn)速度-->
          } 
           function change(){ 
            $("#test").toggle("slow"); 
          <!--設(shè)置以slow的速度打開-->
          } 
        </script> 
      </body> 
    </html> 
    效果圖:
    名單
    以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)jquery程序設(shè)計(jì)有所幫助。