如何用JS控制多个DIV的显示和隐藏有关问题
2个回答
展开全部
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<div class="bb">aaa</div>
<div class="aa">aaa</div>
<div class="aa">aaa</div>
<input type="button" id="ss" value="js"/>
<input type="button" id="sss" value="jq"/>
</body>
<!--js-->
<script>
var $divList = document.getElementsByTagName('div'),
$btn = document.getElementById('ss'),
nowTag = 'none',
otherTag = 'block';
$btn.onclick = function() {
var i = 0,
len = $divList.length;
for(; i < len; i++) {
var $div = $divList[i];
if($div.className === 'aa') {
$div.style.display = nowTag;
}
}
changeTag();
}
function changeTag() {
var temp = nowTag;
nowTag = otherTag;
otherTag = temp;
}
</script>
<!--js end-->
<!--jq start-->
<script src="jq.js"></script>
<script>
$('#sss').on('click', function() {
$('.aa').toggle();
})
</script>
<!--jq end-->
</html>
2015-05-11
展开全部
百度 js tab 切换
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询