我不知道为什么以下内容无法正常工作。
HTML:
JavaScript:
提前感谢您的帮助。
HTML:
...
<div class="col2">
<h2>Your Groups</h2>
<input type="submit" id="addnew" class="btn btn-primary" value="Create New Group"/>
<div id="parent">
<!--new div here-->
</div>
</div>
...
JavaScript:
document.getElementById('addnew').onclick = function(){
var parent = document.getElementById('parent');
var newGroup = document.createElement("div");
newGroup.setAttribute("id", "newGroup");
newGroup.setAttribute("class", "inner");
parent.appendChild(newGroup);
};
提前感谢您的帮助。
newGroup.textContent = "example";