October 9, 201214 yr Hi Guys, I am wondering what the best way to create the following would be: As seen in the picture (design), there are four 'tabs' on the left that control content in the main box to the right. I need to create it so that when one of the tabs is clicked, their respective content is shown in the box on the right and the tab arrow becomes 'active'. You could say I am a novice in terms of coding, so don't feel bad about dumbing it down for me! Many Thanks, Ali
October 9, 201214 yr Hi Guys, I am wondering what the best way to create the following would be: As seen in the picture (design), there are four 'tabs' on the left that control content in the main box to the right. I need to create it so that when one of the tabs is clicked, their respective content is shown in the box on the right and the tab arrow becomes 'active'. You could say I am a novice in terms of coding, so don't feel bad about dumbing it down for me! Many Thanks, Ali Correct me if i'm wrong but you just want to change the main content box with the text of the smaller (left side) box that has been clicked on? If so I would suggest you to use Javascript/Jquery to do this. Let me know here if i'm right and i'll help you coding it.
October 9, 201214 yr You can use this example.. http://www.scriptbreaker.com/javascript/script/JQuery-vertical-tab-menu Just need to customize code as per your requirement.
October 22, 201214 yr Author Correct me if i'm wrong but you just want to change the main content box with the text of the smaller (left side) box that has been clicked on? If so I would suggest you to use Javascript/Jquery to do this. Let me know here if i'm right and i'll help you coding it. Hi Jochemke, I finally have the basics of the site up to start playing about with the coding for this tabbed box. Are you still able to help me with the coding of it? http://silverfernfitness.co.uk Many Thanks! Ali
October 23, 201214 yr Try something like this: Add to your js: $('.tab').on('click', this, function(){ if (($(this).hasClass('tab-active')) { return; } $('.tab').removeClass('tab-active'); $('.box').removeClass('box-active'); $(this).addClass('tab-active'); if ($(this)).hasClass('tab-1') { $('.box-1').addClass('box-active'); } else if ($(this)).hasClass('tab-2') { $('.box-2').addClass('box-active'); } else if ($(this)).hasClass('tab-3') { $('.box-3').addClass('box-active'); } else { $('.box-4').addClass('box-active'); } }); And add to your CSS: .tab a:hover, .tab-active { background: url(images/tab-bg.png) 0px 100px; } .box { display: none; } .box-active { display: block; } Remove the visibility styles from the boxes and add a class of "tab-active" to the first tab and a class of "box-active" to the first box. Can't test it but it should be close, at least. Goodluck, ~evu.
October 25, 201214 yr Author Try something like this: Add to your js: $('.tab').on('click', this, function(){ if (($(this).hasClass('tab-active')) { return; } $('.tab').removeClass('tab-active'); $('.box').removeClass('box-active'); $(this).addClass('tab-active'); if ($(this)).hasClass('tab-1') { $('.box-1').addClass('box-active'); } else if ($(this)).hasClass('tab-2') { $('.box-2').addClass('box-active'); } else if ($(this)).hasClass('tab-3') { $('.box-3').addClass('box-active'); } else { $('.box-4').addClass('box-active'); } }); And add to your CSS: .tab a:hover, .tab-active { background: url(images/tab-bg.png) 0px 100px; } .box { display: none; } .box-active { display: block; } Remove the visibility styles from the boxes and add a class of "tab-active" to the first tab and a class of "box-active" to the first box. Can't test it but it should be close, at least. Goodluck, ~evu. Thanks Evu! Have put your code in. Will see how it turns out once the CSS updates (cheers Varnish Caching!). I have a feeling I may need you to tinker with it a little if you have the time. (But fingers crossed it works straight out!) Thanks, Ali
October 25, 201214 yr Should really tinker with it yourself dude, we help for free, not work for free But there's a typo for starters, remove one of the brackets on the first "if" statement. You'll also need to wrap it in doc ready too. $(document).ready(function() { $('.tab').on('click', this, function(){ if ($(this).hasClass('tab-active')) { return; } $('.tab').removeClass('tab-active'); $('.box').removeClass('box-active'); $(this).addClass('tab-active'); if ($(this).hasClass('tab-1')) { $('.box-1').addClass('box-active'); } else if ($(this).hasClass('tab-2')) { $('.box-2').addClass('box-active'); } else if ($(this).hasClass('tab-3')) { $('.box-3').addClass('box-active'); } else { $('.box-4').addClass('box-active'); } }); }); Goodluck, ~evu. Edited October 25, 201214 yr by evu
October 26, 201214 yr Author Thanks Evu. It's only because I have such little knowledge of JS it'd be like a dog chasing it's tail round in circles all day.
October 26, 201214 yr Author Success! Sort of I think I need to get rid of the anchor and fiddle around but hopefully we are pretty much there now! Thanks Evu, Ali (hopefully you're free now
October 26, 201214 yr hehe, just looked and saw you changing it as I was refreshing Glad you got it working! Changing the anchors into something else is the way to go but just an FYI
October 26, 201214 yr nice site, dont forget to change the colour of the links at the bottom, and re-name the title
Create an account or sign in to comment