<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <style type="text/css"> #divButton { width:100px; height:100px; overflow:hidden; left:100px; top:100px; } </style> </head> <body> <div id="divButton">tttttttttttttt</div> <script type="text/javascript"> var e=document.getElementById("divButton"); for(var i in e.currentStyle){ document.write(i+':'+e.currentStyle[i]+'<br />'); } </script> </body> </html>
var e=document.getElementById("divButton"); for(var i in e.currentStyle){ document.write(i+":" + e.currentStyle[i] + "<br>"); } currentStyle代表了在全局样式表、内嵌样式和 HTML 标签属性中指定的对象格式和样式。
提示:没有权限 错误行:for(var i in e.currentStyle) //本人ie6.0浏览器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
#divButton
{
width:100px;
height:100px;
overflow:hidden;
left:100px;
top:100px;
}
</style>
</head>
<body>
<div id="divButton">tttttttttttttt</div>
<script type="text/javascript">
var e=document.getElementById("divButton");
for(var i in e.currentStyle){
document.write(i+':'+e.currentStyle[i]+'<br />');
}
</script>
</body>
</html>
for(var i in e.currentStyle){
document.write(i+":" + e.currentStyle[i] + "<br>");
}
currentStyle代表了在全局样式表、内嵌样式和 HTML 标签属性中指定的对象格式和样式。
错误行:for(var i in e.currentStyle)
//本人ie6.0浏览器
用Jquery 框架
$("#divButton").css("width","100");""代表你的样式的名字,""代表你修改的样式 就可以变成100 还很很多这个的例子JavaScript不用深学 能用就行 除非你很像研究它