什麼選擇我使用一個類添加到a
元素是自舉導航欄的ul > li
裏面?如何修復jQuery選擇
下面是代碼:
<div class='navbar navbar-inverse' role='navigation'>
<div class='container'>
<!-- Brand and toggle get grouped for better mobile display -->
<div class='navbar-header'>
<a class='navbar-brand' href='#'><img src='' height='41' width='40' alt=''></a>
</div>
<div class='collapse navbar-collapse'>
<ul class='nav navbar-nav navbar-right'>
<li><a class='' id='newsBox' href=''><span class='glyphicon glyphicon-inbox'></span></a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
<button type='button' id='newsBox2' class='btn btn-default'>asdasd</button>
$("#newsBox2").click(function() {
$(".navbar .container ul li a #newsBox").addClass(".news");
});
你有問題發佈相關的代碼 – 2014-11-20 23:00:55
以及我加上http://jsfiddle.net/763h89h9/但我的例子編輯帖子... – 2014-11-20 23:04:15