<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>关于JS使用CSS滤镜的问题</title>
</head><body>
<div id="test">demo</div>
<script type="text/javascript">
document.getElementById('test').filters.alpha.opacity=20; //这句代码报错
</script>
</body>
</html>希望下面回复的,最好给出正确的完整代码,并说明原因。
document.getElementById('test').style.filter = "progid:DXImageTransform.Microsoft.Alpha(sProperties)";
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>关于JS使用CSS滤镜的问题</title>
</head><body>
<img id="test" src="http://avatar.profile.csdn.net/noavatar_2.gif" />
<script type="text/javascript">
document.getElementById('test').style.filter = "alpha(opacity:20)";
</script>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>关于JS使用CSS滤镜的问题</title>
</head><body>
<div id="test" style="zoom:1">demo</div>
<script type="text/javascript">
document.getElementById('test').style.filter = "alpha(opacity:20)";
</script>
</body>
</html>
注意zoom:1。强制ie使用hasLayout