I have the following lack of knowledge on javascript. I have a nav-tab menu with 5 different tabs that can be expanded. But I want when the page loads a spesific tab (based on the previous page or arguments in the url) to be expanded. On the bootstrap page they have the example:
<script>
$(function () {
$('#myTab a:last').tab('show');
})
</script>
My question is that I have no idea what ‘a’ is and I can’t get it to pass an argument so that for instance my second tab to be shown. If I pass integer or #reference instead of ‘last’ it does not work. Anyone knows what is the right syntax here?
I have the following lack of knowledge on javascript. I have a nav-tab menu
Share
#myTab a:lastis a jQuery selector that means “the last<a>tag contained in the element with id#myTab“. So that function runs theshowmethod on the element that matches that selector.If you want to select a different element, you can use any jQuery selector. There are lots of them: CSS standard selectors plus these ones.
For your specific issue, you can select the second tab by passing its
#idor by using:nth-child(2)(wich means “the elements that are a second child”).