I’ve created 3 buttons with a paragraph of content after each, when a button is clicked this will fade in the paragraph that follows it as well as adding an active class to that clicked button. At the moment I have managed to achieve the fade in and fade out but i dont seem to be able to remove the active class from the previous clicked button, can anyone advise where I might be going wrong with this? also there is probably an easier/better way to create the effect Im working towards so all advice/help/suggestions are really welcome.
Fiddle: http://jsfiddle.net/kyllle/nZFUP/3/
Thanks
Kyle
Try removing the
.activeclass from all of the.clickMelinks, then add the.activeclass to the currently clicked link:You could also do some optimization since the same selectors will be used over and over:
Here is an update to your jsfiddle of the above optimization: http://jsfiddle.net/nZFUP/4/