I am trying to make a script that adds a left and right border to a button in a line of 3 buttons when that button is clicked, and keep it with no border otherwise. The code I have so far is:
$("#popular").click(function(){
clearBorders();
//make borders here (this works)
});
$("#suggestions").click(function(){
clearBorders();
//make borders here (this works)
});
$("recent").click(function(){
clearBorders();
//make borders here (this works)
});
function clearBorders(){
$('popular').css("border", "solid");
$('suggestions').css("border", "none");
$('recent').css("border", "none");
}
});
I am able to create the borders fine, but for some reason the clearborders method is not working. I know the function is being called because if I put an alert at the beginning of it, it shows up. Why won’t this function work?
Your selectors are missing the leading id (#) or class (.) designator symbol in your clearBorders() function