您的位置:首页 > Web前端 > JQuery

jQuery实现放大缩小效果

2018-02-28 00:00 597 查看
<!DOCTYPE html>
<html>
<head>
<meta name="Author" content="微普科技http://www.wiipu.com"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>jquery实现点击放大图片</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
#zmkt {
width: 500px;
height: 500px;
background: #D0D0FF;
}
#zmkt .sub {
position: relative;
width: 200px;
height: 200px;
background: red;
}
#zmkt a {
position: absolute;
right: 10px;
top: 10px;
text-decoration: none;
font-size: 14px;
color: #101a0a;
}
</style>
<script src="http://xiguape.wiipu.com/basecode/js/jquery.1.9.1.min.js"></script>
<script type="text/javascript">

$(function(){
var flag=true;
$("a").click(function(){
if(flag){
$(".sub").width("500");
$(".sub").height("500");
$("a").text("缩小");
flag=false;
}else{
$(".sub").width("200");
$(".sub").height("200");
$("a").text("放大");
flag=true;
}

})

});
</script>
</head>
<body>
<!--提示:使用jquery实现点击放大缩小效果,
点击“放大”时红色块与外层div一样大,按钮文字变为“缩小”,
点击“缩小”时,变为原始样子;-->
<div id="zmkt">
<div class="sub"><a href="#">放大</a></div>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息