The common jQuery DOM operations (a)

DOMDivided into three main operations, DOM Core, HTML-DOMandCSS-DOM

Find node

Find an element node

Mainly through jQuerythe selectors to find elements node

Find property node

You may be used to look after the element node attr()to find the corresponding node or set properties

Create a (child) node

Using $(html标签代码字符串)a node is created, and then use the following methods to insert a node; while the following method may also move the original element node

  • append()Additional content to match the interior of each element
  • appendTo()All matched elements added to the specified elements
  • prepend()The contents of each element of the internal head matches
  • prependTo()All the elements of the pre-match to the specified elements
  • after()Insert after each matched elements
  • insertAfter()All the elements that match the specified element is inserted into the rear
  • before()Inserts before each matching element
  • insertBefore()All matched elements inserted in front of the specified element

Delete Node

  • remove()Delete all matched elements from the DOM
  • detach()Cut all the matches from the DOM elements, events, and additional data retention
  • empty()Clear all matched elements from the DOM descendant element node

Copy nodes

  • clone()Copy the elements match

Replacement Node

  • replaceWith()将所有匹配的元素用特定内容替换
  • replaceAll()The same effect, reverses the relationship between the guest of honor

Guess you like

Origin www.cnblogs.com/zxcv123/p/12164083.html