如何使用Dojo动态添加div? [英] How to add a div dynamically by using Dojo?
本文介绍了如何使用Dojo动态添加div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下静态div:
<body>
<div id="div1"></div>
....
我想在div1中添加一个id为div1_1的div动态地使用dojo。我该怎么做?
I want to add a div with id "div1_1" within div1 dynamically by using dojo. How can I do it?
推荐答案
你可以使用Dojo Base&mdash如果您使用中继线或Dojo 1.3,则不需要包含任何内容:
You can do it using just Dojo Base — no need to include anything, if you use the trunk or Dojo 1.3:
dojo.create("div", {id: "div1_1"}, "div1");
此行创建一个id为div1_1的div,并将其附加到id为div1的元素。显然你可以一次性添加更多的属性和样式在 dojo.create()的文档中阅读全文。
This line creates a div with id "div1_1" and appends it to the element with id "div1". Obviously you can add more attributes and styles in one go — read all about it in the documentation for dojo.create().
这篇关于如何使用Dojo动态添加div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文