The pseudo-class selector , unlike the element style in the general DOM, does not alter any DOM content. Just a few elements of the decorated class are inserted, which are visible to the user, but not visible to the DOM. The effect of a pseudo-class can be achieved by adding an actual class.A:link|a:visited|a:hover|a:activeIn the CSS definition, a:hover must be placed a:link and a:visited after, is valid, a:active must be placed a:hover after, is vali
The pseudo-class selector , unlike the element style in the general DOM, does not alter any DOM content. Just a few elements of the decorated class are inserted, which are visible to the user, but not visible to the DOM. The effect of a pseudo-class can be achieved by adding an actual class.A:link|a:visited|a:hover|a:activeIn the CSS definition, a:hover must be placed a:link and a:visited after, is valid, a:active must be placed a:hover after, is vali
.
6+1=7 7+1=8 8+1=9
Yang Publishing House
The following is the CSS link table a:hover{color:palevioletred;} a:active{Color:yellow;} a:visited{color:red;} /*p:nth-child (2n) {*//*color:blanchedalmond;*//*}*//*p:nth-child (2n-1) {*//*color:yellow;*//*}*//*p:first-child{ *//*color:red;*//*}*//*p:last-child{*/
The jquery selector draws on the CSS selector, and the core still relies on JavaScript's getElementById () and getElementsByTagName () methods, but he encapsulates 2 ways to make the jquery selector simple and easy to use.And it avoids the problem of error-prone.The jquery selector returns an array object and returns an empty array if the specified element is not found.So when you decide if a jquery object exists, you can't use the following statement
Efficiency of selectors in jq and efficiency of jq selectors
$ ('. Class') $ ('div. class') $ ('div. class') execution efficiency
$ ('. Class')> $ ('div. class')> $ ('div. class ')Cause:
$ ('. Class') is equivalent to calling the doucmen. getElementsByClassName () method in native js. It will be slow in earlier versions of ie, but it will be fast in later versions of browsers.
$ ('Div. class') is equiva
We can use CSS in HTML using inline styles, internal styles, and external styles, but how are styles in CSS related to specific HTML tags? This is the function of the selector, there are a lot of selectors in the CSS, here we summarize some of the most common selectors, in a
The code is as follows
Copy Code
Usage examples:
The code is as follows
Copy Code
IE and FireFox will automatically add some rules, such as you only define BORDER:1PX solid #eee;
Maybe You've learned three simple and common selectors for css: #ID,. class, tag selector, but is that enough? With the advent of CSS3 , as the front-end developers need to master the following 30 basic selectors, so that in peacetime development in the heart with the HANDS.This article will synthesize the 30 CSS3 selectors
Jquery-selectors-lastchild Select the last child element
Selectors/lastchild
From jQuery JavaScript Library
: Last-child OverviewMatches all elements this are the last child of their parent. While:last matches only a single element, this matches the more then one:one for each parent.Demo Finds the last span in each matched div and adds some CSS plus a hover s
, event binding, animation, and then to its internal source schemaFor analysis, so today, let's look at its style operations, style operations, that is, the CSS style of theFor1 $ (' #box ')//ID selector 2 $ ('. Demo ')// class selector 3 $ (' div ') Tag name selector 4 $ (' * ')// full selector 56 Here are a few selectors that we often use, in JavaScript we also have, where we use the dollar sign $To mak
Select
Label
9. button usage
Definition: match all buttons
Returned value: Array Example: change the background color of all buttons in the DIV with ID "div_i1" to red.
Code: $ ("# div_i1: button" ).css ("background-color", "red"); // click "9" to run the code div id = "div_i1"
Span ID = "span_1"
texteara
Select
Label
Note: reset and submit are not selected!10.: file Usage
Definition: match all file Domains
Returned value: A
jquery: First-child Selector Usage InstanceThis selector can match the first child element of the parent element.Syntax structure:$ (": First-child")This selector is typically used in conjunction with other selectors, such as class selectors, element selectors, and so on. For example:$ ("ul Li:first-child"). CSS ("Colo
= 'checkbox']: checked)" ground .css ("background-color", "red "); // click "3" to execute the code div id = "div_c1"
Span ID = "span_c1"
DIV id = "div_c1_1"
DIV id = "div_c1_2"
DIV id = "div_c1_3"
DIV id = "div_c1_4"
Note: For details about how to use has (selector), see content visibility section 3rd. For details about [type = 'checkbox'] usage, see attribute section 2nd.
4.: selected usageDefinition: match all selected option ElementsR
The CSS selector is weighted, and when the style settings for the different selectors conflict, the style is set with a high weight selector.If the CSS selector weights the same, the style follows the nearest principle, which selector is the last defined, and which selector style is used.If you ignore the CSS selector
their color to red.8 Selector1 > Selector2: Sub-selectorDiv#container > UL { border:1px solid black;}It differs from the direct sub-element that the following command chooses it. Look at the following example#container > ulOnly id div all direct elements under ' container ' are selected ul . It does not navigate to elements such as the first one li ul .For some reasons, using a sub-node combination selector can have many advantages over performance. In fact,
The power of the jquery selector is not only that the selector supports basic CSS selectors, but also many CSS pseudo class selectors and even custom selectors, let's look at some pseudo class selectors
: Usage of Nth-childNth-ch
-child "). css ("background-color", "red"); // click the button 4 to execute this code div id = "div_d1"
Ul id = "ul_d1"
LI: C
LI: C ++
LI: C #
LI: Java
LI: JavaScript
Ul id = "ul_d2"
LI: Google
LI: Microsoft
LI: Apple
LI: Sun
LI: Intel
Ul id = "ul_d3"
Li: onle one
Div id = "div_d5"
Article introduction:
Use of jQuery-Selectors (selector) (1. Basic)
Use of jQuery-
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.