I have the following bootstrap pills on page1.htm:
<div>
<ul class="nav nav-pills nav-stacked" >
<li role="presentation" class=""><a href="someurl.htm#apply" class="js-apply">Apply</a></li>
<li role="presentation" class=""><a href="someurl.html#report" class="js-report">Report</a></li>
<li role="presentation" class=""><a href="someurl.html#book" class="js-book">Book</a></li>
</ul>
</div>
on page2.htm I have the following link
<a class="btn btn-default" href="page1.htm#apply" role="button">Apply</a>
When I click the above link to go to page1.htm, how do I extract the anchor id attribute from the url to set list item on page1.htm with the same anchor id attribute to active i.e. the following list tag should become active:
<li role="presentation" class="active"><a href="someurl.htm#apply" >Apply</a></li>
Similarly if I click the following link, I want to set the list item on page1.htm with the same anchor id attribute to active.
<a class="btn btn-default" href="page1.htm#report" role="button">Apply</a>
I use the following to get the hash:
var url = document.location.toString(), idx = url.indexOf("#")
var hash = idx != -1 ? url.substring(idx+1) : "";