<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>图片放大和缩小</title>
<script>
var width=img1.width;
var height=img1.height;
function da(){
if(img1.height<=img1.height*2 ||img1.width<=img1.width*2){
img1.height=img1.height+20;
img1.width=img1.width+20;
}
}
function xiao(){
if(img1.height>100 ||img1.width>100){
img1.height=img1.height-20;
img1.width=img1.width-20;
}
}
</script>
</head>
<body>
<div id = a align="center">
<img src="images/6.jpg" id ="img1">
</div>
<div align="center">
<input type="button" value="放大" οnclick="da()">
<input type="button" value="缩小" οnclick="xiao()">
</div>
</body>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>图片放大和缩小</title>
<script>
var width=img1.width;
var height=img1.height;
function da(){
if(img1.height<=img1.height*2 ||img1.width<=img1.width*2){
img1.height=img1.height+20;
img1.width=img1.width+20;
}
}
function xiao(){
if(img1.height>100 ||img1.width>100){
img1.height=img1.height-20;
img1.width=img1.width-20;
}
}
</script>
</head>
<body>
<div id = a align="center">
<img src="images/6.jpg" id ="img1">
</div>
<div align="center">
<input type="button" value="放大" οnclick="da()">
<input type="button" value="缩小" οnclick="xiao()">
</div>
</body>
</html>
点击放大按钮,放大图片
点击缩小按钮,缩小图片