5_jQuery选择器

时间:2023-03-09 04:07:44
5_jQuery选择器

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>new_</title>
<meta name="author" content="gy" />
<!-- Date: 2017-02-20 -->
<script src="jQuery1.11.1.js"></script>
<script type="text/javascript">
window.onload = function() {

//并集
//$("div,#NEW").css("background-color","blue");

//交集 (两个标签都具有的元素)
//$("div#NEW").css("background-color","blue");

//全局 (全部)
//$("*").css("background-color","blue");//自动迭代

//后代 ()
//$("#hh span").css("background-color","blue");

//子
//$("#hh>#NEW").css("background-color", "blue");

//相邻
//$("#NEW+.tet").css("background-color","blue");

//同辈
//$("#NEW~span").css("background-color","blue");

//复合选择器
$("#hh div[id=NEW]").css("background-color","blue");

//

};

</script>
</head>
<body>
<div id="hh">
<DIV id="NEW">
第一个div
</DIV>
+b
<span class="tet"> 我是span</span>
<div>
第二个div
</div>
</div>
</body>
</html>