Sharp jquery-DOM operations, jquery-dom

Source: Internet
Author: User

Sharp jquery-DOM operations, jquery-dom
1. Search nodes ① you can search Nodes Based on the jquery selector ② available. text () to get the text content of the node ③ available. attr ("attr") obtains the attribute value2 to create a node. ① The jquery factory function can be used to complete $ (html) eg: $ ("<li> </li> ") you can add text and properties for the label at the same time. 3. Insert node ① method (see the document). ② The method can not only insert nodes, you can also move a node. 4. delete a node. ① remove () remove all matching elements. ② detach () remove all matching elements, unlike remove, the removed content retains sample data. All bound events and additional data are retained. ③ empty () clears nodes, clear all child nodes of matching elements, including content 5 Copy nodes ① clone (true) Copy matched nodes; if the input parameter is true, the binding event 6 of the element is copied to replace node ① replaceWith () eg:. replaceWith (B) B replace A ② replaceAll () and replaceWith () replace and replaced node opposite 7 Package node ① package node. wrap ("<B> </B>") uses the <B> label to wrap A. If A is A multi-node object, A <B> label Package A for each node. wrapAll ("<B> </B>") if A is A multi-node object, A label is provided for the object, and all nodes are wrapped in A. B label. wrapInner ("<B> </B>") provides A <B> label 8 attribute operation ① To obtain and set attribute A for each node that matches the tag object. attr ("title");. attr ("title", "value") ② Delete attribute. removeAttr ("title"); 9. style operations ① get and set styles (operate class attributes) E. attr ("class"); E. attr ("class", "value"); ② append style addClass ("className") append a className ③ remove style removeClass ("className") Remove a className ④ switch style. toggleClass ("className") removes the class if the style exists. If not, add the clss ⑤ to determine whether a style exists. hasClass ("className") determines whether a class is contained; 10 sets and obtains HTML, text, and value 1. the html () method is similar to the innerHTML method in js. Set and obtain the HTML content in the element. 2. the text () method is similar to the innerText method in js. It sets and obtains the text value 3 in the element. the val () method is used to set and obtain the value attribute in the element. If multiple elements are selected, an array 11 matching node is returned for search ①. children () searches for all child nodes that match nodes. (Only child nodes are considered, and other child nodes are not considered.) ②. next ()/. prev ()/siblings () searches for peer elements matching nodes (Back/Front/All); ③. parent ()/. parents () Find the parent element of the matching node 12 css-dom operation ① get/set the style value $ ("E" ).css ("cssAttr ") $ ("E" ).css ("cssAttr", "value"); ②. offset ()/. position () is used to obtain the left/top value offset or set the position value relative to the window value to obtain or set the value relative to the first absolute or relative positioning ancestor element ③. scrollTop ()/. scrollLeft () gets or sets the distance between the scroll bar and the top or left side.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.