<div id="divMain" title="aa" style="color:red;">
<div id="s">aaaaaaq</div></div>
<script>/*function copyElement(o)
{
var newObject = document.createElement("div");
newObject.innerHTML=o.innerHTML; for( i=0;i<o.attributes.length;i++)
{
//alert();
newObject.setAttribute([o.attributes[i].nodeName],o.attributes[i].nodeValue);
document.write(o.attributes[i].nodeName+":"+o.attributes[i].nodeValue+"<br>");
}
document.body.appendChild(newObject);
}
copyElement(document.getElementById("divMain"));
*/
document.write(document.getElementById("divMain").attributes["style"].nodeValue);//为什么输出 null ?
</script>
<div id="s">aaaaaaq</div></div>
<script>/*function copyElement(o)
{
var newObject = document.createElement("div");
newObject.innerHTML=o.innerHTML; for( i=0;i<o.attributes.length;i++)
{
//alert();
newObject.setAttribute([o.attributes[i].nodeName],o.attributes[i].nodeValue);
document.write(o.attributes[i].nodeName+":"+o.attributes[i].nodeValue+"<br>");
}
document.body.appendChild(newObject);
}
copyElement(document.getElementById("divMain"));
*/
document.write(document.getElementById("divMain").attributes["style"].nodeValue);//为什么输出 null ?
</script>
解决方案 »
- js控制wmv播放问题
- 【请教】在iframe中使用dojo弹出widget窗口,怎样找到该iframe?
- jQuery 动态折叠显示问题
- ExtJs 做的一棵导航树,出现莫名错误
- document.all.WebBrowser.ExecWB的问题
- 大家好, 如果用js判断一个对象的存在?
- 怎么实现点击过的文字链接颜色有变化?让人知道他看过这个帖子。
- 大家好,帮我看一下这段代码吧,关于单选按扭提交,再线等待!!
- 在左边框的隐藏菜单与显示菜单怎么做的呢
- 求助求助,ie8,ie9下问题
- 在asp中用javascript的alert输出的是乱码,怎么解决?
- 请教javascript高手。能否帮我把这两段代码合在一起。
怎样枚举style的每个属性其实我想复制一个层及其所有子元素 例如 www.live.com 那样托动时的效果
var s="";
for(p in o.style){
s=s+p+":"+o.style[p]+"\n";
}
alert(s);
里面重要的一个属性就是cssText
o.style.cssText,以分号隔开
可以自己进行处理