首页 > 其他 > 详细

jq 写选项卡可以多简单?

时间:2019-06-29 22:02:43      阅读:96      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="../js/jquery.min.js"></script>
<style>
input{width: 30px;height: 10px;}
#div1 div{width: 100px;height: 100px;border:1px solid #333;display: none}
.active{background: #f00}
</style>
</head>
<body>
<div id="div1">
<div style="display: block">11</div>
<div>22</div>
<div>33</div>
<input type="button" class="active"/>
<input type="button" />
<input type="button" />
</div>
<script>
$(function(){
$("#div1").find("input").click(function(){
$(this).attr("class","active").siblings("input").attr("class","");
$("#div1").find("div").eq($(this).index(‘input‘)).css("display",‘block‘).siblings("div").css("display",‘none‘)
})
})
</script>
</body>
</html>

jq 写选项卡可以多简单?

原文:https://www.cnblogs.com/hilxj/p/11107666.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!