enter image description here当用户点击链接
时,我想关注li标签<li id="secondli"><a onclick="showscndbox();" id="secondlink" >How can I upload with my membership?</a></li>// tab to be clicked
<div class="col-md-12 col-sm-12 col-xs-12" id="secondbox" style="display:none;" >
<div class="col-md-12 col-sm-12 col-xs-12 pro-box-in-faq" >
content to hide or show
</div>
</div>
有19个li
代码,我想让li
代码可以点击并让其他div隐藏
function showthrdbox() {
//ta
document.getElementById("thirdbox").style.display = "block";
$("#thrdli").attr('tabindex',2).focus();
document.getElementById("secondli").removeAttr('tabindex');
document.getElementById("secondbox").style.display = "none";
}
此脚本专注于所点击的li
标记,但不会让另一个div
隐藏。请让我知道解决方案。
答案 0 :(得分:0)
function showscndbox(e) {
var anchor = e.target;
var p = anchor.parentNode;
var pp = p.parentNode;
for (var i in pp.childNodes) {
var child = pp.childNodes[i];
if (child != p) {
child.style.display = "none";
}
}
p.style.display = "";
}