vincej Posted January 21, 2015 Share Posted January 21, 2015 I work with PHP and I'm not good with JS. I want to use a Twitter Boostrap tab funnction: http://getbootstrap.com/javascript/#tabs I need some guidance how it uses the JS code mentioned. The code below taken from the Bootstrap page is obvious enough: $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') }) What I do not understand is how I am required to use the following code in the context of the previous code. Ok, I get that I have to choose one option, but I don't get how they fit together and I do not get how I can have 5-7 tabs and how they will be highlighted one after the other as per the given example on the Bootstrap page : $('#myTab a[href="#profile"]').tab('show') // Select tab by name $('#myTab a:first').tab('show') // Select first tab $('#myTab a:last').tab('show') // Select last tab $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) Many thanks for all your help ! Quote Link to comment https://forums.phpfreaks.com/topic/294095-js-noob-need-help-with-some-bootstrap-javascript/ Share on other sites More sharing options...
scootstah Posted January 22, 2015 Share Posted January 22, 2015 $('#myTab a[href="#profile"]').tab('show') // Select tab by name $('#myTab a:first').tab('show') // Select first tab $('#myTab a:last').tab('show') // Select last tab $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed)This is just showing ways that you can select specific tabs if you wanted to. All you should need for basic tabs is this: $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') })This will call "show" on the tab that was clicked on. Quote Link to comment https://forums.phpfreaks.com/topic/294095-js-noob-need-help-with-some-bootstrap-javascript/#findComment-1503752 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.