蛇精脸视频百度网盘:jquery 简单学习(5)

来源:百度文库 编辑:九乡新闻网 时间:2024/07/04 20:09:05

JQuery简单学习(5)——JQuery效果

文章分类:Web前端

 

jQuery 是为事件处理特别设计的。

————————————————————jQuery 事件函数隐藏、显示、切换、滑动 以及动画实例jQuery hide() Js代码  
  1.   
  2.   
  3.   
  4. "text/javascript" src="/jquery/jquery.js">   
  5. "text/javascript">   
  6. $(document).ready(function(){   
  7.   $("p").click(function(){   
  8.   $(this).hide();   
  9.   });   
  10. });   
  11.   
  12.   
  13.   
  14.   
  15. If you click on me, I will disappear.

      
  16.   
  17.   
  18.    
 演示简单的 jQuery hide() 函数。 
jQuery hide() Js代码  
  1.   
  2.   
  3. "text/javascript" src="/jquery/jquery.js">   
  4. "text/javascript">   
  5. $(document).ready(function(){   
  6. $(".ex .hide").click(function(){   
  7. $(this).parents(".ex").hide("slow");   
  8. });   
  9. });   
  10.   
  11. "text/css">    
  12. div.ex   
  13. {   
  14. background-color:#e5eecc;   
  15. padding:7px;   
  16. border:solid 1px #c3c3c3;   
  17. }   
  18.   
  19.   
  20.     
  21.   
  22.   
  23. Island Trading

      
  24. class="ex">   
  25. class="hide" type="button">Hide me   
  26. Contact: Helen Bennett    

  27. Garden House Crowther Way   
  28. London

      
  
  •   
  • Paris Trading

      
  • class="ex">   
  • class="hide" type="button">Hide me   
  • Contact: Marie Bertrand    

  • 265, Boulevard Charonne   
  • Paris

      
  •   
  •   
  •   
  •   
  •  另一个 hide() 演示。如何隐藏部分文本。 
    jQuery slideToggle() Js代码  
    1.   
    2.   
    3.   
    4. "text/javascript" src="/jquery/jquery.js">   
    5. "text/javascript">    
    6. $(document).ready(function(){   
    7. $(".flip").click(function(){   
    8.     $(".panel").slideToggle("slow");   
    9.   });   
    10. });   
    11.   
    12.     
    13. "text/css">    
    14. div.panel,p.flip   
    15. {   
    16. margin:0px;   
    17. padding:5px;   
    18. text-align:center;   
    19. background:#e5eecc;   
    20. border:solid 1px #c3c3c3;   
    21. }   
    22. div.panel   
    23. {   
    24. height:120px;   
    25. display:none;   
    26. }   
    27.   
    28.   
    29.     
    30.   
    31.     
    32. class="panel">   
    33. Because time is valuable, we deliver quick and easy learning.

        
    34. At W3School, you can study everything you need to learn, in an accessible and handy format.

        
      
  •     
  • class="flip">Show/Hide Panel

      
  •     
  •   
  •   
  •  演示简单的 slide panel 效果。 
    jQuery fadeTo() Js代码  
    1.   
    2.   
    3. "text/javascript" src="/jquery/jquery.js">   
    4. "text/javascript">   
    5. $(document).ready(function(){   
    6.   $("button").click(function(){   
    7.   $("div").fadeTo("slow",0.25);   
    8.   });   
    9. });   
    10.   
    11.   
    12.   
    13.   
    14. "test" style="background:yellow;width:300px;height:300px">   
    15. "button">Click to Fade   
      
  •   
  •   
  •   
  •   
  •  演示简单的 jQuery fadeTo() 函数。 
    jQuery animate() Js代码  
    1.   
    2.   
    3. "text/javascript" src="/jquery/jquery.js">   
    4. "text/javascript">    
    5. $(document).ready(function(){   
    6.   $("#start").click(function(){   
    7.   $("#box").animate({height:300},"slow");   
    8.   $("#box").animate({width:300},"slow");   
    9.   $("#box").animate({height:100},"slow");   
    10.   $("#box").animate({width:100},"slow");   
    11.   });   
    12. });   
    13.     
    14.   
    15.     
    16.   
    17.   
    18. "#" id="start">Start Animation

        
    19.   
    20. "box"  
    21. style="background:#98bf21;height:100px;width:100px;position:relative">