I two pages home.html and service.html. On the home page when this link a href="services#v-pills-manpower"
is clicked on, I want to add show active
class to the div on the service page with the id #v-pills-manpower
.
This is the html in my service.html
<div class="tab-pane fade show active" id="v-pills-services"></div>
<div class="tab-pane fade" id="v-pills-manpower"></div>
This is the javascript
var hash = document.location.hash;
var pills = document.querySelectorAll('*[id]');
if($.inArray(hash, pills)) {
// console.log(hash + 'is in IDs array');
// Add show active class to the div with the hash id
}
How can i achieve my goal?