I'm playing around with some Jquery as a hobby and I've run into a problem with changing the attribute of whatever the user clicks on. I have a bunch of tabs and didn't want to have create an event thingy for each of them, so I'm trying to put it all into one.
Sorry if it's a bit unclear, I don't really know the vocab of Jquery things.
var tabSelected = "default";
$('body').on("click",".subtab", function() {
var tabChosen = this.id;
tabChosen = tabChosen.substring(0, tabChosen.length-1); //cuts off T
tabChosen = "'#" + tabChosen + "'"; //puts into '#id' format
$(tabChosen).css('background-color','#E53939');
$(tabSelected).css('background-color','#FFFFFF');
tabSelected = tabChosen;
});
For clarification I use separate ID's for tabs and subtabs, so for the div with Home id, the id of the subtab clicked is HomeT. The TabChosen then would be HomeT, which I've been trying to manipulate into the usual $('#id') thing I use, where the id has to be Home not HomeT.
I'm trying to change the color of whatever was clicked. In addition, I want the tab that the user was on to change back to the default color.
Any help is appreciated.