有没有办法在div的末尾创建并附加dijit?说我有以下代码:
<div id="attendants">
</div>
<button dojoType="dijit.form.Button" onClick="addPerson();">Add Person</button>
我在网上找到了以下代码,但这取代了我的'服务员'div:
var personCount = 0;
function addPerson() {
personCount += 1;
var attendants = dojo.byId('attendants');
var newField = new dijit.form.TextBox({id: 'newPerson' + personCount, name: 'newPerson' + personCount}, attendants);
}
我希望动态地将新的TextBox dijit添加到div中,而不是用dijit替换div。
答案 0 :(得分:2)
// place a new button as the first element of some div
var button = new dijit.form.Button({ label:"click" }).placeAt("wrapper","first");