Use of jquery-selectors (selector) (vii. subelement)
This series Article This article mainly describes how to use selectors in the jquery framework. I will describe them in the form of examples. It is based on simplicity and comprehensiveness and will not be very deep. My learning method is as follows: getting started, advanced!This series of articles includes nine articles: basic articles, level articles,
this case, the 'careful process' is set to green, but the # test span with a higher weight is set to red. The child selector inadvertently affects the newly added code. To meet our expectations, rewrite the Code as follows:
Very important. We need to handle it with caution.
What happens if solution 2 is used?
The CSS selector weight is very important, so we should be careful with it.
Because there is no sub-selector, We can mount the new class for th
course, this is only the simplest case. The $ notation in this case is actually called getElementById (), but the complexity of the case is accomplished through the jquery selector.How is the jquery selector implemented?That's what the world has to say: JQuery uses CSS selectors to select HTML elements. I personally feel more and more nonsense. So it is still suggested how to use can look at the user, the
attribute value to info $ (' input[placeholder^= "info"]); Select all the elements that are tagged as input and filter the placeholder attribute value to the element starting with info $ (' input[placeholder$= "tion"] '); Select all the elements that are tagged as input and filter the placeholder attribute value to tion the end of the element $ (' input[placeholder*= "mat"] '); Select all elements that are tagged as input and filter the element containing the field mat in the
JQuery examples and important jQuery selectors are required.What can Jquery do?
Access and operate DOM elements
Control page styles
Process page events
New jQuery Extension
Perfect Combination with Ajax technology
Advantages of Jquery
Small Size, only about KB after compression
L powerful Selector
Excellent DOM Encapsulation
L reliable event processing mechanism
Excellent browser compatibility
Simplified programming using implicit Iteratio
The common use of the "short form of jquery () functions" of the $ () function(1) Wrapping DOM elements for ease of operation (jquery selector)(2) As a namespace prefix for several common utility functions, for example, a utility function that deletes a space before and after a string, and calls the method as follows:$.trim (str);(3) Document-Ready handler: Wraps the document instance, then calls the Ready () method, executes the function when the document is prepared for operation(4) Creating D
the 8.[attribute!=value] property selector is to get all elements that do not contain the property name, or that are not the same as the property name and the property value.Where [] is a brace character that is dedicated to the property selector, the parameter attribute represents the property name, and the value parameter represents the property values.$ ("li[title!= ' My Favorite ')") property selector code, gets the specified 9. A more powerful property selector [Attribute*=value], which ca
jquery selectors are a feature of the jquery library, which not only eliminates tedious javascript writing, but also saves time and efficiency, and it's the jquery selectors that make it easier to manipulate the DOM of JavaScript. 1. Basic selector• #id match an element based on the given ID. For example: $ ("#id") element matches all elements according to the given element name. For example: $ ("div") ·. c
with the development of jquery, more and more people have begun to understand jquery, and slowly like her, she is so concise, so fascinating, and attracted a group of enthusiasts for her wedding dress. Well, let me introduce the jquery selector. the selectors in jquery have many classes, such as the ID selector, the class selector, the HTML tag Selector, and so on. ID Selector: It is the ID of an HTML element to select it, because the ID in the HTML i
Jquery has three selectors: Element selector, attribute selector, and CSS selector.
Element selector:
$ ("P") Select the
$ ("P. Intro") select all
$ ("P # Demo") Select the first
Attribute selector:
Jquery uses an XPATH expression to select an element with a given attribute.
$ ("[Href]") selects all elements with the href attribute.
$ ("[Href = '#']") select all elements with an href value equal.
$ ("[
The jquery selector is very powerful and very flexible. The basic selector is the most commonly used in our programming, although the jquery version has now been developed into the 2.x version, but the basic selector has not changed, that is, there are only 5 kinds.1. ID Selector, format #idThe element is selected based on the value of the id attribute for the given element. If the id attribute value contains special characters, the desired element cannot be selected and can be escaped by 2 slas
jquery selectors, when separated by commas, need to be aware of the scope issues:@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%> StringPath=Request.getcontextpath (); StringBasePath=Request.getscheme ()+ "://" +Request.getservername ()+ ":" +Request.getserverport ()+Path+ "/";%>DOCTYPE HTML>HTML>Head>Basehref= ">MetaCharSet= "UTF-8">title>B Indextitle>Linkrel= ' stylesheet 'type= "Text/css
With the Jquery selector, the food is delicious and the body is superb ......1. Basic We know that jquery is the most commonly used selector. Let's take a look at the selector in jqueryAPI-there are five situations: class, id, element, *, and a multi-selector, here we want to write the css styleCss styles also have several situations: 1. Class styles 2. id styles 3. Label styles,If there is an aa class, we need to write the aa style as. aa {}If there
Many times we can't find the element we want directly with the base selector and the hierarchy selector, and for this jquery provides a series of filter selectors to find the DOM elements that are needed more quickly. Many of the filter selectors are not CSS specifications, but jquery's own selector for the convenience of developers
The usage of the filter sele
: A
Matches the first element found
Matches the selected element.
return value
Element
Example
Find the first row of a table
HTML Code:
JQuery Code:
$ ("Tr:first")
Results:
[
---------------------------------------------------------------------------------------
: Last
Match the last element found
Matches the last selected element.
return value
Element
Example
Find the last row in a table
HTML Code:
JQue
The jquery selector is very powerful and very flexible. The basic selector is the most commonly used in our programming, although the jquery version has now been developed into the 2.x version, but the basic selector has not changed, that is, there are only 5 kinds.
1. ID Selector, format #id
The element is selected based on the value of the id attribute for the given element. If the id attribute value contains special characters, the desired element cannot be selected and can be escaped by 2 s
Common relationship-based selectors
Selector Selector
The selected element
A E
Any descendant element e of element A (descendant node refers to a child node, child node, and so on)
A > E
Any of the element A's child elements E (that is, direct descendants)
E:first-child
Either is the element of the first child node of its parent junction E
B + E
Any o
JQuery element SelectorJQuery uses CSS selectors to select HTML elements.$ ("P") select the $ ("P.intro") selects all the $ ("P#demo") selects all JQuery Property SelectorJQuery uses an XPath expression to select an element with a given property.$ ("[href]") selects all elements with an href attribute.$ ("[href= ' # ']") selects all elements with an HREF value equal to "#".$ ("[href!= ' # ']") selects all e
. Here's how to use selectors:$("#myELement"Select an element with an ID value equal to myelement, the ID value cannot be duplicated in the document only one ID value is myelement so get the unique element $ ("Div"Select all div tag elements, return the DIV element array $ (". MyClass"Select all elements of CSS using the MyClass class $ ("*"Select all the elements in the document, and you can select them in
elements of the id= "test"Tip: The syntax used by JQuery is a combination of XPath and CSS selector syntax. In the next chapters of this tutorial, you will learn more about selectors Syntax./*************************deom1**********************************//*************************deom2**********************************/ /*************************deom3**********************************/ /******************
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.