jQuery entry function, DOM object into a set css style selector intersection and union Usage

1.jQuery entry function (function can be written a plurality of inlets)

jQuery entry function faster than the entry function window.onload
window.onload entry can only perform one function

It is equivalent and jQuery $ is a function
entry function usage
d O c in m e n t . r e a d Y f in n c t i O n ) ; (Document) .ready (function () {}); or (function () {}); $
usage
$ (div) Gets jQuery object
$ ( '# one'); character selector
$ ( '

I jQuery
'); Create a label
$ (dom object); dom objects will be converted into jQuery object

jQuery object transformed into an object:

1. Use subscripts to take out, assuming the object is a jQuery d i v div, which is one of the objects div [0], i.e., d i v d o m 2. 使 j Q u e r y g e t div one object is taken out of the object 2. dom jQuery object inside the get () method, div.get (0) to inside a subject can be taken out of the object is dom

difference jQuery objects and dom object
dom is the object native js selector acquired only call dom method or property
jQuery object is jQuery select an object acquired only call jQuery method or property and not native js method and property

text () function usage
1. Do not give argument is to get the text
includes multiple jQuery object dom element with text () Gets the text, the text will get to all dom elements (implicit iteration)
2.text ( "I am the xx ")
to set the text content elements, the text will overwrite the original content

css () is set to acquire style

1. Obtain style css () method to set the parameter values to get the name of the style
pattern comprises acquiring a plurality of elements dom jQuery object to obtain only the first pattern dom element
2 disposed style
setting style single
css (Style name , style value)
set multi-style
css ({})

jQuery selector intersection and union usage

Union l i . n j ( "Li, .nj") intersection ( "li.nj")
level selector
$ ( "ul> li") acquired son-level elements and grandchildren will not get
$ ( "ul li") descendant selector, All elements including li son and li of
the filter selector
$ ( "li: eq (2wherein 2 index, starting from 0
$: ( "li odd") odd-
even number: ( "even li") $
filter Selector
u l . c h i l d r e n l i ( "Ul"). Children ( "li") corresponds to the subclass selector ( "ul-li")
u l . f i n d l i ( "Ul"). Find ( "li") is equivalent to descendant selectors ( "UL Li")
$ ( "UL"). SIBLINGS ( "Li") Find sibling does not include its own itself
$ ( "li"). parentto find his father
l i . e q 2 ( "Li"). Eq (2) corresponding to ( "li: eq (2)as the index, from zero
. Find the next sibling $ ( "Li") Next ()
$ ( "Li ") .prev () to find a brother

Released seven original articles · won praise 0 · Views 6

Guess you like

Origin blog.csdn.net/weixin_45221036/article/details/104993339