Getting Started with Dojo: DOM operations

Source: Internet
Author: User

As a fully functional JS Toolkit, Dojo provides a unified approach to DOM manipulation.

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 obviously short and easy to write.

Dojo.query

Although Dojo.byid can easily get a DOM node based on the ID, it is almost impossible to get each element based on the ID, because the ID is uniquely identified. If you want to get a few elements at once, we can pass the Dojo.query method.

The Dojo.query function takes a string argument and uses a CSS3 selector to refer to the element you want to select. This works much like jquery's manipulation of the DOM. If we want to get all the elements of a class in a page, we just need to use the following code:

Dojo.query (". Class")

This method will return a nodelist, and we can manipulate each element by traversing the list.

Dojo.body

The Dojo.body method returns the BODY element of document

Dojo.create

Dojo.create method creates an element

Dojo.destroy

The Dojo.destroy method removes the element from the parent element and deletes all child elements of the element

Dojo.empty

The Dojo.empty method removes all child elements

Dojo.foreach

The Dojo.foreach method allows an iterator to be defined for an array or a nodelist to access each item in the arrays or nodelist and to provide the appropriate action.

This method ignores the return value and does not support break.

Getting Started with Dojo: DOM operations

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.