小白提问:用JS实现图片大小改变的不解
<!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=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function func1()
{
var wid=parseInt(document.getElementById("pic").style.width);
document.getElementById("pic").style.width=wid+5+"px";
}
</script>
</head>
<body>
<a href="#" onmousemove="func1()"><img src="image/1.jpg" width="300" height="200" id="pic" /></a>
</body>
</html>
当我用上面的代码时为什么图片的宽度没有改变?
但如果把函数func1里的代码改为
document.getElementById("pic").style.width=305+"px";
图片的大小就可以改变了。