Style attributes and basic understanding of the operation jquery

Jquery is a feature-rich library js

Js library: js file encapsulates a lot of ways, the introduction to when needed.

The entry function Jquery

1.$(function(){…})

2.$(document).ready(function(){……})

Features: Awaiting i.e. execute code page loads; sandbox is formed, to prevent pollution of the global variables

And window.onload difference:

It can support multiple write, will not cover, there is a coverage problem window.onload;

jquery will perform in advance at the time of execution, without waiting for pictures to load

 

Jquery objects and objects dom

Dom Objects: js dom, it will get the page element is an object dom

Jquery Objects: jquery way, get the object to get the page element, that is, jquery object

The association between the two and their mutual conversion

Dom Jquery object is a collection of objects stored inside a lot of objects dom; pseudo object is an array jQuery

Jquery objects and object attributes method can not be mixed dom

Jquery objects can be taken out by the object is a subscript dom

Precautions: .get method is acquired dom objects; .EQ () is acquired jquery object

 

The selector Jquery

Filter selector: $ ( 'li: odd') to find the odd subscripts li, index starts from 0

$ ( 'Li: even')

:first

:last

:eq()

: Selected (checked disabled) find selected

Filter Selector

.next () next sibling element

.prev on () a sibling

.siblings () all of the siblings, not including their own

.children () all offspring

.parent () to find the parent element

.eq (index) to find the next element corresponding to the subject, index starts from 0

.find () to find descendants

 

Css method manipulation pattern

1. Set a single style css (name, value)

2. A plurality of styles css (obj)

3. Gets the style css (name) is acquired by the first element of style

 

The method of operation of the class name of the class

1. addClass () add class

2. removeClass () remove class

3. hasClass () determines a class as long as there are elements in this class element returns true

4. toggleClass () class switch

 

jquery attribute manipulation

attr

1. Set a single attribute attr (name, value)

2. plurality of attributes attr (obj)

3. Get attribute attr (name)

4. Remove property removeAttr (name)

 

Prop special operation boolean attributes [disabled checked selected]

Prop (checked) Gets

Prop (checked, true) Set

Guess you like

Origin www.cnblogs.com/z-lin/p/11101940.html