日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

dojo 的DOM操作 dojo/dom

發(fā)布時(shí)間:2024/1/23 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dojo 的DOM操作 dojo/dom 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
對(duì)dom的使用,需要引用包dojo/dom。
1.獲取節(jié)點(diǎn), dom.byId
byId中既可以傳遞一個(gè)字符串,也可以傳遞一個(gè)節(jié)點(diǎn)對(duì)象 require(["dojo/dom", "dojo/domReady!"],function(dom) { ????? ????function setText(node, text){ ????????node = dom.byId(node);//通過(guò)已有對(duì)象 ????????node.innerHTML = text; ????} ????var one = dom.byId("one");//通過(guò)字符串 ????setText(one, "One has been set"); ????setText("two", "Two has been set as well"); ????? });



<!DOCTYPE html>

<html> <head> <metacharset="utf-8"> <title>Demo: DOM Functions</title> <scriptsrc="//ajax.googleapis.com/ajax/libs/dojo/1.7.8/dojo/dojo.js" data-dojo-config="async: true"> </script> <script> require(["dojo/domReady!"],function() { ? }); </script> </head> <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> </html>



// Require the DOM resource

require(["dojo/dom","dojo/domReady!"], function(dom) { ? functionsetText(node, text){ node = dom.byId(node); node.innerHTML = text; } ? varone = dom.byId("one"); setText(one,"One has been set"); setText("two","Two has been set as well"); ? });


The arguments to domConstruct.create are as follows: node name as a string, properties of the node as an object, an optional parent or sibling node, and an optional position in reference to the parent or sibling node (which defaults to "last").It returns the new DOM element node. Let's take a look at an example:

require(["dojo/dom","dojo/dom-construct", "dojo/domReady!"],

function(dom, domConstruct) { ? varlist = dom.byId("list"), three = dom.byId("three"); ? domConstruct.create("li", { innerHTML:"Six" }, list); ? domConstruct.create("li", { innerHTML:"Seven", className:"seven", style: { fontWeight:"bold" } }, list); ? domConstruct.create("li", { innerHTML:"Three and a half" }, three,"after"); ? });

總結(jié)

以上是生活随笔為你收集整理的dojo 的DOM操作 dojo/dom的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。