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?
问问题
1873 次
1 回答
3
#myTab a:last
is a jQuery selector that means "the last <a>
tag contained in the element with id #myTab
". So that function runs the show
method 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 #id
or by using :nth-child(2)
(wich means "the elements that are a second child").
于 2012-09-12T19:33:44.070 回答