views:

1350

answers:

3

I have a the following static div:

<body>
  <div id="div1"></div>
....

I want to add a div with id "div1_1" within div1 dynamically by using dojo. How can I do it?

+1  A: 
dojo.html.set(dojo.byId("div1"), "<div id='div1_1'></div>");
Maurice Perry
I think I need to add dojo.request("...") for dojo.html. What is the package?
David.Chu.ca
sorry, it should be something like dojo.require(...)
David.Chu.ca
got it: dojo.require("dojo.html");
David.Chu.ca
right, sorry about that: I fell asleep
Maurice Perry
+4  A: 
Eugene Lazutkin
A: 
var divNode = document.createElement("div");
div.id = "div1_1";
document.body.appendChild( divNode );

This is a good way, it helps get past some node referencing issues in IE7 and you can continue to use the reference to the divNode later.