当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jQuery使用一个按钮控制图片的伸缩实现思路

jQuery使用一个按钮控制图片的伸缩实现思路

2018年12月26日  | 移动技术网IT编程  | 我要评论

代码如下:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "https://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#img1
{
width: 500px;
height: 400px;
border: solid 1px #ccc;
display:none;
}
</style>
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
var count = 0;
$(function () {
$('#button1').click(function () {
if (count % 2 != 0) {
$('#img1').hide(5000);
}
else {
$('#img1').show(5000);
}
count++;
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<p>
<img id="img1" src="images/1.jpg" />
<input id="button1" type="button" value="点我看看" />
</p>
</form>
</body>
</html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网