Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<script src= "Js/jquery-1.3.2.js" ></script>
<script type= "Text/javascript" ><!--
$ (function () {
$ ("#aContains"). Click (function () {
$ ("Div:contains (' Hello ')"). each (function () {
$ (this). CSS ("Background", "Red");
})
})
$ ("#aEmpty"). Click (function () {
$ ("Div:empty"). each (function () {
$ (this). HTML ("Emptydiv");
})
})
$ ("#aHas"). Click (function () {
$ ("Div:has (P)"). each (function () {
$ (this). CSS ("Background", "Red");
})
})
$ ("#aParent"). Click (function () {
$ ("Div:parent"). each (function () {
$ (this). CSS ("Background", "Red");
})
})
})
--></script>
<body>
<div id = "DIV1" >
<p>hello word!</p>
</div>
<div id = "Div2" >
Hello
</div>
<div id = "Div3" height= "20px" >
</div>
<div id = "DIV4" ></div>
<a href= "#" id= "Acontains" > Set content contains "Hello" node red background color </a>
<a href= "#" id= "Aempty" > Set Content-free div content to emptydiv</a>
<a href= "#" id= "AHAs" > Set div node with p node red background color </a>
<a href= "#" id= "aparent" > Set div node containing child nodes red background color </a>
</body>
First of all, this chapter on the extracurricular knowledge points under the description
1.element.css ("AttributeName", "value")
Description: The style used to set the element, in the example $ (this). CSS ("Background", "red"), or set the node's background to red.
Now, let's go to the subject.
1.$ ("tagname:contains (' keyword ')")
Description: Used to get a collection of nodes containing keyword content in all tagname nodes
return value: Array (Element);
2.$ ("Tagname:empty")
Description: Used to get a collection of nodes with empty content in all tagname nodes
return value: Array (Element);
3.$ ("Tagname1:has (TagName2)")
Description: Used to get the collection of nodes in all TAGNAME1 nodes that contain TagName2 child nodes
return value: Array (Element);
4.$ ("Tagname:parent")
Description: Used to get a collection of nodes in all tagname nodes that contain child nodes
return value: Array (Element);