如何创建动态div
问题描述:
如何为Mozilla Firefox使用Java脚本创建动态div.
以及如何在div中创建Div
将Mozilla Firefox的Java脚本用于高度宽度,该高度可在Java脚本页面上动态更改.
How to create dynamic div using java script for Mozilla Firefox.
And how to create Div inside div
using java script for Mozilla Firefox with height width which is change dynamically on java script page.
答
请参见以下javascript函数.
See following javascript function.
function create_div_dynamic(){
dv = document.createElement(''div''); // create dynamically div tag
dv.setAttribute(''id'',"lyr1"); //give id to it
dv.className="top"; // set the style classname
//set the inner styling of the div tag
dv.style.position="absolute";
dv.style.pixelLeft=20;
dv.style.pixelTop=100;
dv.style.pixelWidth=10;
dv.style.pixelHeight=20;
dv.style.backgroundColor="red";
//set the html content inside the div tag
dv.innerHTML=''<br> hi <br>'';
//finally add the div id to ur form
document.forms[0].appendChild(dv);
}
如果您认为答案合适,请投票
Vote up if you consider the answer suitable