JQuery Learning Note Selector four _jquery

Source: Internet
Author: User
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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.