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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

dojo中的dojo/dom-construct

發布時間:2024/1/23 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dojo中的dojo/dom-construct 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

首先是引用:

require(["dojo/dom-construct"], function(domConstruct){});

dom-construct主要包含如下方法:

1.toDom()

require(["dojo/dom-construct", "dojo/dom", "dojo/on", "dojo/domReady!"], function(domConstruct, dom, on){on(dom.byId("button1"), "click", function(){var row = domConstruct.toDom("<tr><td>bar</td><td>Bar is also good</td></tr>");domConstruct.place(row, "example");}); });

Here is our HTML <table> which we will add the row to.

<button id="button1" type="button">Add a row</button> <table><thead><tr><th>Example</th><th>Description</th></tr></thead><tbody id="example"><tr><td>foo</td><td>Foo is good</td></tr></tbody> </table>

2.place()

require(["dojo/dom-construct", "dojo/dom", "dojo/on", "dojo/domReady!"], function(domConstruct, dom, on){var n = 0;on(dom.byId("placeBA"), "click", function(){domConstruct.place("<div class='node'>new node #" + (++n) + "</div>", "refBA",dom.byId("posBA").value); // before/after}); }); <p><button id="placeBA">Place node</button><select id="posBA"><option value="before">before</option><option value="after">after</option></select> </p> <p><div>before: 1st</div><div>before: 2nd</div><div id="refBA" class="ref"><div class="child">the reference node's child #0</div><div class="child">the reference node's child #1</div><div class="child">the reference node's child #2</div></div><div>after: 1st</div><div>after: 2nd</div> </p> div.ref { background-color: #fcc; } div.node { background-color: #cfc; } div.child { background-color: #ffc; } div.ref div { margin-left: 3em; }

3.create()

Append a new <div> to<body> with no attributes:

require(["dojo/dom-construct", "dojo/_base/window"], function(domConstruct, win){var n = domConstruct.create("div", null, win.body()); });

Place a new <div> as the first child of<body> with no attributes:

require(["dojo/dom-construct", "dojo/_base/window"], function(domConstruct, win){var n = domConstruct.create("div", null, win.body(), "first"); });

4.empty()

require(["dojo/dom-construct"], function(domConstruct){// Empty node's children byId:domConstruct.empty("someId"); });

5destory()

require(["dojo/dom-construct", "dojo/dom", "dojo/on", "dojo/domReady!"], function(domConstruct, dom, on){on(dom.byId("progButtonNode"), "click", function(){domConstruct.destroy("testnode1");dom.byId("result1").innerHTML = "TestNode1 has been destroyed.";}); });

Some DomNodes

<div id="testnode1">TestNode 1</div> <button id="progButtonNode" type="button">Destroy TestNode1</button> <div id="result1"></div>

具體應用看官網例子:http://dojotoolkit.org/reference-guide/1.10/dojo/dom-construct.html




總結

以上是生活随笔為你收集整理的dojo中的dojo/dom-construct的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。