Blogger Information
Blog 31
fans 0
comment 0
visits 18297
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS第4课-jquery演示和选择器-九期线上班
Content っ
Original
527 people have browsed it

1、写出课堂上讲解的jquery 的6个选择器,并说明其含义

  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. </head>
  8. <body>
  9. <div id="div1" class="class1" style="background-color: red">
  10. <p id="p1" class="c1">1</p>
  11. <p id="p2" class="c2">2</p>
  12. </div>
  13. <div id="div2" class="class1" style="background-color: green">
  14. <p id="p3" class="c3">3</p>
  15. <ul>
  16. <li>12</li>
  17. <li>11</li>
  18. <li> <p id="p7" class="c7">8</p></li>
  19. </ul>
  20. </div>
  21. <p id="p6" class="c6">6</p>
  22. <div id="div3" class="class3" style="background-color: blue">
  23. <p id="p5" class="c5">5</p>
  24. </div>
  25. <div id="div4" class="class4" style="background-color: orange">
  26. <ul>
  27. <li>12</li>
  28. <li>11</li>
  29. <li> <p id="p4" class="c4">4</p></li>
  30. </ul>
  31. </div>
  32. <!--/***********JS**********/-->
  33. <script>
  34. //id选择器
  35. var div1 = $("#div1");
  36. console.log(div1);
  37. var p2 = $("#p2");
  38. console.log(p2);
  39. //类选择器
  40. var class1 = $(".class1");
  41. console.log(class1);
  42. var c3 = $(".c3");
  43. console.log(c3);
  44. //通配符选择器
  45. var div = $("div");
  46. console.log(div);
  47. var p = $("p");
  48. console.log(p);
  49. //后代选择器
  50. var div2 = $("div p");
  51. console.log(div2);
  52. var p3 = $("ul li");
  53. console.log(p3);
  54. //子类选择器
  55. var div3 = $("#div2 > p");
  56. console.log(div3);
  57. var pp = $("body > p");
  58. console.log(pp);
  59. //后面一个
  60. var g = $("#div2 + p");
  61. console.log(g);
  62. var h = $("#div3 + p");
  63. console.log(h);
  64. //后面的所有
  65. var t = $("#div1 ~ div");
  66. console.log(t);
  67. var s = $("#p1 ~ p");
  68. console.log(s);
  69. </script>
  70. </body>
  71. </html>

总结
今天学习了jquery,jquery就是封装好的js类库,大大的简化了代码。然后学习了jquery的选择器,和css的一样。

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