动态创建DIV:var div = document.createElement("div");
设置div属性及样式等:
div.title="this is a new div.";
div.class = "newDivClass";
div.innerHTML = "Test create a div element!";
div.style.styleFloat="left";
div.style.overflow="hidden";
div.style.marginLeft="8px";
div.style.marginTop="10px";
div.style.width="320px";
div.style.height="250px";
div.style.backgroundRepeat="no-repeat";
div.style.backgroundImage="url(image/bgred.jpg)"
将DIV添加到body:document.body.appendChild(div );
设置Attribute属性:
添加,设置:
(1). div.setAttribute("ok","ok?");
html:
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号