Dojo (2) Basic DOM operation

1. Get DOM node

dojo.byId(param) param: can be a node ID name or a node

2. Add DOM node

dojo.create(node,nodeObject,nodeRelation,nodeLocation)
node:node name
nodeObject:Node attributes{innerHTML:”,className:”,style:{fontWeight:’bold’}} < /div>

nodeRelation: the parent or sibling of the node
nodeLocation: relative position to nodeRelation node, (first,before,after,last(default))
3 .Insert DOM node

dojo.place(node,relationNode,location)
node: insert node < /div>

relationNode: reference node
location: relative position (first, before, after, last(default))

4. Delete DOM node

dojo.destory()Delete this node and its children
dojo.empty() Delete this node

5. Batch operation

Dojo query, the return value is Array
dojo.query(“#id”) [index]According to ID strong>
dojo.query(“.class”) [index]according to class

< div> Limited query

dojo.query(“#list #one”)Query the entire DOM tree
dojo.query(“#one”,dojo.byId(“list”))Query in the qualified conditions(Use qualified query as much as possible to improve efficiency)
Other queries
The incoming parameters are: tag name and class namedojo.query(” a.one”)
6.NodeList
dojo.query() returns The result set is NodeList

Common methods:

< div>

1.forEach(functio n(node,index,nodelist){ }) Traverse

2.< span style="white-space:pre">style,replaceClass,addClass,place,empty, etc. These methods all return nodeList, which can be used in series
dojo.query(‘#red’).removeClass(‘red’).addClass(‘black’) span>

3.connect connect to DOM events, not applicable include Large number of nodes

dojo.byId(param)param: can be a node ID name or a node


2. Add DOM node


dojo.create(node,nodeObject,nodeRelation,nodeLocation)

node :Node name

nodeObject :Node attributes{innerHTML:”,className:”,style:{fontWeight:’bold’}}

nodeRelation: the parent or sibling of the node

nodeLocation: relative position to nodeRelation node,(first,before,after,last(default))

3. Insert DOM node


dojo.place(node,relationNode,location)

node: insert node

relationNode: reference node

location: relative position (first, before, after, last (default) )


4. Delete DOM node


dojo.destory()Delete the node and its children

dojo.empty() Delete the node


5. Batch Operation


Dojo query, The return value is array

dojo.query(“#id”) [index]According to ID < /span>

dojo.query(“.class”) [index]according to class


Restricted query

dojo. query(“#list #one”)Query the entire DOM tree

dojo.query(“#one”,dojo.byId(“list”)) Query in qualified conditions (Use qualified queries as much as possible to improve efficiency) p>

Other queries

< span style="white-space:pre"> The incoming parameters are: tag name and class namedojo.query(“a.one”)

6.NodeList

The result set returned by dojo.query() is NodeList


Common methods:

< strong>

1.forEach(function(node,index,nodelist){ }) Traverse


2.style, replaceClass, addClass, place, empty, etc., these methods are Return to nodeList, which can be used in series

dojo.query( ‘#red’).removeClass(‘red’).addClass(‘black’)


< /p>

3.connect connect to DOM events, Not applicable to situations that contain a large number of nodes

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5757 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.