Dojo Operations Dom

Source: Internet
Author: User

The operation of Dom (Document Object Model) is a job for browser-side JavaScript, and Dojo provides some handy and ingenious ways to expand, replace, and add to HTML when the browser loads, we can take advantage of these simple , efficient, browser-and-use approach to achieve this goal.
I. Search
Let's take a look at the following example:
<! DOCTYPE html>
<metacharset= "Utf-8" >
<title>demo:dom functions</title>
<scriptsrc= "Http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js"
data-dojo-config= "Async:true" >
</script>
<script>
Require (["dojo/domready!"],function () {

});
</script>
<body>
<ulid= "List" >
<liid= "One" >One</li>
<liid= "Two" >Two</li>
<liid= "three" >Three</li>
<liid= "Four" >Four</li>
<liid= "Five" >Five</li>
</ul>
</body>
The dojo tag is already written, you need to identify the require block.
All of the DOM's code to be manipulated will not be executed until the DOM is finished loading. The first thing we might want to know is how we document objects from the Document Object model. The easiest way to do this is through the Dojo/dom Resource Byid () method when we pass an ID to the Dom.byid () method you will receive the corresponding document node object, and if no matching object is found, the null value is returned.
This method is equivalent to document.getElementById
But the benefits of using Byid are:
1. He's shorter.
2. Better browser compatibility
3. When passed to him is a text object, he will immediately return to himself.

For example
Require the DOM Resource
Require (["Dojo/dom", "dojo/domready!"],function (DOM) {
Functionsettext (node, text) {
node = Dom.byid (node);
node.innerhtml = text;
}

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.