Entry to dojo: Dom operations

Source: Internet
Author: User

As a fully functional JS toolkit, Dojo provides a unified Dom operation method.

Dojo. byid

The dojo. byid function allows you to select a DOM node through the ID attribute. This function is an alias for the standard document. getelementbyid function, but it is short and easy to write.

 

Dojo. Query

Although dojo. byid can easily obtain a DOM node by ID, it is almost impossible to obtain each element by ID because ID is a unique identifier. To obtain several elements at a time, we can use the dojo. query method.

The dojo. query function accepts a string parameter and uses a css3 selector to reference the element you want to select. This operation is similar to jquery's Dom operations. To obtain all the elements of a class on the page, you only need to use the followingCode:

 
Dojo. Query (". Class ")

 

This method returnsNodelist. We can traverse this list to operate each element.

 

Dojo. Body

The dojo. Body method returns the body element of the document.

 

Dojo. Create

The dojo. Create method creates an element.

 

Dojo. Destroy

The dojo. Destroy method deletes this element from the parent element and deletes all child elements of this element.

 

Dojo. Empty

The dojo. Empty method deletes all child elements.

 

Dojo. foreach

The dojo. foreach method allows you to define an iterator for an array or nodelist to access each item in an array or nodelist and provide corresponding operations.

This method ignores the returned values and does not support break.

 

There are also many other useful methods that can be viewed in the http://dojotoolkit.org/api/

Related Article

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.