freeCodeCamp/guide/chinese/certifications/front-end-libraries/jquery/target-html-elements-with-s.../index.md

769 B
Raw Blame History

title localeTitle
Target HTML Elements with Selectors Using jQuery 使用选择器使用jQuery定位HTML元素
  • JQuery选择器允许您选择和操作HTML元素。
  • 这些选择器以美元符号和括号开头:$
  • 您可以根据名称ID类型属性属性值等“查找”或选择HTML元素。

//You can select all <p> elements on a page like this  =  $("p") 
  $(document).ready(function(){ 
    $("button").click(function(){ 
        $("p").hide(); 
    }); 
 }); 

<script> 
  $(document).ready(function() { 
      $("button").addClass("animated bounce"); // We are selecting the button elements and adding "animated bounce" class to them. 
  }); 
 </script>