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;
}