為何沒有作用呢?求助
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-1.8.1.min.js" ></script>
<style type="text/css">
.box{
? ? width: 500px;
? ? margin: 0 auto;
}
.box img{
? ? width: 300px;
? ? height: 400px;
}
</style>
</head>
<body>
<div>
? ? <img src="1.jpg" id="myimage"><br />
? ? <input type="button" value="放大" id="max" />
? ? <input type="button" value="縮小" id="min" />
</div>
<script type="text/javascript">
? ? window.onload = function(){
? ? ? ? var maxbtn =document.getElementById('max');
? ? ? ? maxbtn.onclick =function(){
? ? ? ? ? ? maxfun();
? ? ? ? }
? ? }
? ? var img =document.getElementById('myimage');
? ? function maxfun(){
? ? ? ? var endwidth =img.width*1.3;
? ? ? ? var maxtime =setInterval(function(){
? ? ? ? ? ? img.width = img.width*1.05;
? ? ? ? ? ? img.height = img.height*1.05;
? ? ? ? },20);
? ? }
</script>
</body>
</html>
2015-12-28
因?yàn)槟銢]有設(shè)置if條件