Home > front end >  JQueryDOM object to summarize
JQueryDOM object to summarize

Time:09-20

JQueryDOM object summary
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ the development tools and key technology in Visual Studio 2015 jQuery
Author: wen-jian tang
Writing time: on April 30, 2020,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
In JQ object provides methods of JS can't use JS provides methods in JQ cannot use
Obviously in JQ compared with the operation of the JS JQ operation method is more convenient than JS, JS to memory operating method of a node
Browser is compatible and JQ doesn't have to go to tube compared to the amount of code JQ is far below the JS code,
How to get the JS object into a JQ object?
This method is very simple,
Column: DOM object into a jQuery object
Var box=document. GetElementById (" box ");//DOM object
$(box);//the jQuery object

The jQuery object into a DOM object
Column: var $divs=$(" div ") : this is JQ object
Var div=$divs [0] : this for the DOM object
Using the get () method in jQuery conversion, only need to provide an index can
Var div=$divs. Get (0);//$divs index of 0 element in the object into a DOM object
The common element in JQ for:
Var s=$(" # div ") for an element ID
Var s=$(" div ") to obtain a certain element of the tag
Var s=$(" div ") for an element class
Node deletion:
Remove: this can Remove node
The Empty: delete match all the child nodes in the collection
Detach (separation) : this method is different from the remove only the literal is removed, removed the data will be preserved,
Create nodes:
Created in JQ point method:
$(" body "), append (div); Explain the body for a div
$(" b "). AppendTo (v); Add in the b v
Var div=$(" & lt; Div class='box' & gt; This is a through the jQuery dynamically add div
" );
Nodes of the external insert:
After and beter
Through after insert element after select elements, columns: $(" x "). After (" s ");
Through beter before selecting elements inserted element, columns: $(" x "). Beter (" s ");
InsertAfter and insertBefore
Through insertAfter after select elements inserted element, columns: $(" x "). InsertAfter (" s ");
Through the insertBefore before selecting element insert element, columns: $(" x "). InsertBefore (" s ");
Similar with the get (index), but the get (index) returns the DOM object,
Parameter description: index an integer, indicator elements based on the zero position, from 0 to calculate the position of the element,
- index an integer, the location of the indicator elements, starting from the last element of a set of reciprocal, (1) count
The first () for the first element
The last () to obtain the final element
HasClass (class) to check if the current element contains a particular class, if you have, then return true
This is actually is (". "+ class),
Filter (expr | obj | ele | fn) filter, the set of matched elements with a specified expression
This method is used to narrow the scope of the match, use a comma to separate multiple expression
Find (expr | obj | ele)
Search all of the matched elements with a specified expression, this function is to find the elements that are dealing with a good way to descendants of the element

CodePudding user response:

  • Related