Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Davis Rousseau
6,670 PointsLinking directly to a tab
How can I use a link from another page to open a page and to start in a specific tab?
Here's my tabs page http://codepen.io/davisrousseaudesign/pen/mAjxw
2 Answers
Ron McCranie
7,837 PointsI forked your pen at: http://codepen.io/UncleRemus/pen/ogLNxa?tab=.bed
You can use the query string of the url to specify the tab you want to go to on page load.
?tab=.cubicle
I made some jQuery at the bottom of the document ready function that will look at the url and break out each value in the query string into an array. Then you can look for the 'tab' value. Let me know if you need some further explanation on what i did after you look at it.
P.S. I noticed the first method you were calling in the document ready was throwing an 'undefined' error in the console. I guess the tabs() method is undefined. I commented it out so it wouldn't stop the javascript from finishing.
Davis Rousseau
6,670 PointsWow thanks! If you can point me out to where you learned this that would be great.