1 作用
jQuery选择器是用来选择标签元素的
选择规则和css样式一样
2 代码示例
// 以上省略...<script src="js/jquery-1.12.4.min.js"></script><script>$(function(){// 标签选择器var $p = $("p");alert($p.length); // 2// 通过 jquery设置标签的样式$p.css({"color":"red"});// 类选择器var $div = $(".div1"); // 1alert($div.length);// id选择器var box = $("#box1");alert(box.length); // 1// 层级选择器var h1 = $("div h1");alert(h1.length); // 1// 属性选择器var $input = $("input[type=text]");alert($input.length); // 1});</script></head><body><p>hello</p><p>hello</p><div class="div1">哈哈</div><div id="box1">嘻嘻</div><div><h1>呵呵</h1></div><input type="text"><input type="button"></body></html>
