I'm using Bootstrap to create a nav menu. The nav is loaded into the asdf2.html page using jQuery load(). I am having difficulty adding the "active" class to the subLink when the user goes to asdf2.html.
How can I add the active class to the sublink when the user loads asdf2.html? I belive the div is causing issues but I'm not exactly sure why...
asdf2.html (loads the sub-nav.html page into the sub-nav div and adds the active class to links):
<div id="sub-nav"></div>
<script>
jQuery(function(){
$('#sub-nav').load('sub-nav.html', function() {
$('#sub-nav a:contains("Link")').parent().addClass('active'); //WORKS
$('#sub-nav a:contains("subLink")').parent().addClass('active'); //DOESN'T WORK
})
});
</script>
sub-nav.html (li in the div doesn't addClass):
<div class="well sidebar-nav span3" style="margin-left:0px;">
<ul class="nav nav-list">
<li><a href="asdf.html">Link</a></li>
<div>
<li><a href="asdf2.html">subLink</a></li>
</div>
</ul>
</div>