Use the jquery Content filter selector to select an element instance to explain _jquery

Source: Internet
Author: User
Copy Code code as follows:

<!--
Content Filter Selector: Gets the element based on the text content in the element or the contained child element feature, and the text content can be positioned in a fuzzy or absolute match
jquery Selector Detailed
Depending on the elements in the obtained page, you can divide the jquery selector into: basic selector, hierarchy selector, filter selector, form selector four categories. Among them, in the filter selector can be divided into: Simple filter selector, Content filter selector, visibility filter selector, attribute filter selector, child element filter selector, Form object attribute filter Selector 6 kinds
-->
<title></title>
<!--Use the jquery content filter selector to select elements: In the page, create four <div> tags as needed and add a <span> tag to the <div> in which the remaining <div> tag, get the specified element from the content filter and display it in the page. -->
<script src= "Jquery-1.9.1.js" type= "Text/javascript" ></script>
<style type= "Text/css" >
Body{font-size:12px;text-align:center}
Div{float:left;border:solid 1px #ccc; Margin:8px;width:65px;height:65px;display:none}
Span{float:left;border:solid 1px #ccc; Margin:8px;width:45px;height:45px;background-color: #eee}
</style>
<script type= "Text/javascript" >
$ (function () {//display elements containing given text
$ ("Div:contains (' A ')"). CSS (' Display ', ' block ');
})
$ (function () {//display all empty elements that do not contain child elements or text
$ (' Div:empty '). CSS (' Display ', ' block ');
})
$ (function () {//display element with selector matching
$ (' Div:has (span) '). CSS (' Display ', ' block ');
})
$ (function () {//Display elements that contain child elements or text
$ (' div:parent '). CSS (' Display ', ' block ');
})
</script>
<!--Note: In: Contains (text) content Filter selector, if you are looking for letters, there are case differences-->
<body>
<div>ABCD</div>
<div><span></span></div>
<div>EFAH</div>
<div></div>
</body>

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.