I'm new to jQuery, so I'm sorry if this is a silly question. But I've been looking through Stack Overflow and I can find things that half work, I just can't get it to fully work.
I have 2 tabs - 1 is active, the other is not. Once the inactive tab is clicked, I want that to be given the class of active, and the previous active class to be removed. And vice versa each time an inactive tab is clicked.
Any help would be great!
Here's what I currently have:
http://jsfiddle.net/zLpe5/
Here's what I've tried for adding and removing the class:
$(document).ready(function() {
$(".tab").click(function () {
$(".tab").removeClass("active");
$(".tab").addClass("active");
});
});
If anybody could help with with merging the 2 bits of script in my fiddle that'd be a massive help too. As I'm quite confused about how that's done!
Thank you :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…