Home Web Front-end JS Tutorial JQuery Study Notes Selector 5_jquery

JQuery Study Notes Selector 5_jquery

May 16, 2016 pm 06:49 PM
jquery study notes Selector

Copy code The code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.3.2.js"></script>
<script type="text/javascript"><!--
    $(function(){
            $("#aFirst").click(function(){
                    $("div[id]").each(function(){
                        $(this).css("background","#773300");
                    })
            })
            $("#aSecond").click(function(){
                    $("div[id = div2]").each(function(){
                         $(this).css("background","#8833ff");
                    })
            })
            $("#aThird").click(function(){
                    $("div[id != div2]").each(function(){
                         $(this).css("background","#87f289");
                    })
            })
            $("#aFourthly").click(function(){
                    $("div[name ^= DIV]").each(function(){
                         $(this).css("background","#140586");
                    })
            })
            $("#aFifthly").click(function(){
                    $("div[name $= ly]").each(function(){
                         $(this).css("background","#930584");
                    })
            })
            $("#aSixth").click(function(){
                    $("div[name *= th]").each(function(){
                         $(this).css("background","#099483");
                    })
            })
               $("#aSeventh").click(function(){
                                                                                                                     🎜>                     $(this).css("background", "#938607");                                                            / --></script>
<title>Untitled Document</title>
</head>
<body>
<a href="#" onclick="javascript:location.reload(); ">Reset</a>
<div id="div1" name ="DIV_First">div1</div>
<div id="div2" name ="DIV_Second"&gt ;div2</div>
<div id="div3" name = "DIV_Third">div3</div>
<div id="div4" name = "DIV_Fourthly">div4</ div>
<div id="div5" name="Fifthly">div5</div>

<a href="#" id="aFirst">Set all DIVs on the page Element's background color</a>|
<a href="#" id="aSecond">Set the background color of the second DIV</a>|
<a href= "#" id="aThird">Set the background color of DIVs except the second DIV</a>|
<a href="#" id="aFourthly">Set the name attribute value to Elements starting with DIV</a>|
<a href="#" id="aFifthly">Set the name attribute value Elements ending with ly</a>|
<a href ="#" id="aSixth">Set the element whose name attribute value contains th</a>|
<a href="#" id="aSeventh">Comprehensive application</a>

</body>
</html>


1.$("selector [Attribute]")--Note, the following is directly abbreviated as [Attribute]
Description: Get the set of elements with the Attribute attribute in the set of elements selected by the selector. It should be relatively simple, so I won’t explain it in detail here. If you don’t understand, please post it below.
Return value: Array(Element);
2.[attribute=value]
Description: Get In the set of elements selected by the selector, the set of elements with an Attribute attribute value equal to Value.
Return value: Array(Element);
3.[attribute!=value]
Description: Get the set of elements whose Attribute attribute value is not equal to Value in the set of elements selected by the selector.
Return value: Array(Element);
4.[attribute^=value]
Description: Get the set of elements whose Attribute attribute value starts with Value in the set of elements selected by the selector. Equivalent to the regular specification ^^
Return value: Array(Element);
5.[attribute$=value]
Description: Get the Attribute attribute value ending with Value in the set of elements selected by the selector Collection of elements. Equivalent to the regular specification ^^
Return value: Array(Element);
6.[attribute*=value]
Description: Get the elements whose Attribute attribute value contains Value in the set of elements selected by the selector. gather.
Return value: Array(Element);
7.[selector1][selector2][selectorN]
Description: Same as the comprehensive application of basic selectors in Chapter 1, this method is also the first 6 The comprehensive version, just like in my example $("div[id][name !=Fifthly][name *= i]") is to take all div elements that have ID attributes&&name attributes!=Fifthly&&name attributes that contain the character i A collection of DIV elements. If you try it with my example, you will be able to clearly understand and see the effect, haha. It should be useful to make good use of this method^^
Return value: Array(Element);
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute?

Summary of commonly used file operation functions in PHP Summary of commonly used file operation functions in PHP Apr 03, 2024 pm 02:52 PM

Summary of commonly used file operation functions in PHP

See all articles