Blogger Information
Blog 36
fans 1
comment 0
visits 28738
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
12月24日jQuery事件-jQuery动画-九期线上班
WJF
Original
1196 people have browsed it

jQuery事件


  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>jQuery事件</title>
  6. <script src="jquery-3.4.1.min.js"></script>
  7. <style>
  8. #phpcn{
  9. background-color: #0C9A9A;
  10. border-radius: 2px;
  11. padding: 20px;
  12. }
  13. button{
  14. background-color: #0E9A00;
  15. border: 0;
  16. border-radius: 2px;
  17. padding: 10px;
  18. margin-top: 5px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <button id="btn1">按钮1</button>
  24. <button id="btn2">按钮2</button>
  25. <button id="btn3" onclick="offw()">移除button所有事件</button>
  26. <button id="btn4" onclick="onew()">ONE</button>
  27. </body>
  28. <script>
  29. //one 第一次点击先添加元素 第二次点击时执行
  30. function onew(){
  31. $('button').one('click',function () {
  32. $('#btn4').after('<p id="phpcn">php</p>');
  33. })
  34. }
  35. //移除指定类元素事件
  36. function offw(){
  37. $('button').off()
  38. }
  39. $('#btn1').on('click',function () {
  40. alert('按钮1被点击了')
  41. });
  42. $('#btn2').on( "click", function() {
  43. alert($( this ).text() + '666' );
  44. });
  45. </script>
  46. </html>


jQuery动画


  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>jQuery动画</title>
  6. <script src="jquery-3.4.1.min.js"></script>
  7. <style>
  8. #phpcn{
  9. background-color: #0C9A9A;
  10. border-radius: 2px;
  11. padding: 20px;
  12. }
  13. button{
  14. background-color: #0E9A00;
  15. border: 0;
  16. border-radius: 2px;
  17. padding: 10px;
  18. margin-top: 5px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div id="nav">
  24. <p>AA</p>
  25. <p>BB</p>
  26. <p>CC</p>
  27. </div>
  28. <button onclick="hidet()">隐藏#NAV</button>
  29. <button onclick="showt()">显示#NAV</button>
  30. <button onclick="slideUpt()">滑动隐藏#NAV</button>
  31. <button onclick="slideDownt()">滑动显示#NAV</button>
  32. <button onclick="slideTogglet()">滑动显示+隐藏#NAV</button>
  33. <button onclick="fadeInt()">淡入显示#NAV</button>
  34. <button onclick="fadeOutt()">淡出隐藏#NAV</button>
  35. </body>
  36. <script>
  37. //淡出隐藏 fadeOut
  38. function fadeOutt() {
  39. $('#nav').fadeOut(1000);
  40. }
  41. //淡入显示 fadeIn
  42. function fadeInt() {
  43. $('#nav').fadeIn(1000);
  44. }
  45. //滑动显示+隐藏 slideTogglet
  46. function slideTogglet() {
  47. $('#nav').slideToggle();
  48. }
  49. //滑动显示 slideDownt
  50. function slideDownt() {
  51. $('#nav').slideDown();
  52. }
  53. //滑动隐藏 slideUp
  54. function slideUpt() {
  55. $('#nav').slideUp();
  56. }
  57. //隐藏 hide
  58. function hidet() {
  59. $('#nav').hide();
  60. }
  61. //显示 show
  62. function showt() {
  63. $('#nav').show();
  64. }
  65. </script>
  66. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:这些基本的动画还是很简单的吧
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post