我们来看看所有的jQuery选择器。
正如您在上一课中看到的,jQuery选择器以美元符号和圆括号开头:$()。
最基本的选择器是元素选择器,它根据元素名称选择所有元素。
$("div") // selects all <div> elements接下来是id和类选择器,它们通过id和类名来选择元素:
$("#test") // select the element with the id="test"
$(".menu") //selects all elements with class="menu" 您还可以对选择器使用以下语法:
$("div.menu") // all <div> elements with class="menu"
$("p:first") // the first <p> element
$("h1, p") // all <h1> and all <p> elements
$("div p") // all <p> elements that are descendants of a <div> element
$("*") // all elements of the DOM选择器比纯JavaScript更容易访问HTML DOM元素。
("P ")

$("div > ")