I have some code that makes the background color of a div fade. The code is currently working the way I want it to, but I would like to replace part of it with a variable so I can change which div(s) it will affect. The div that it is affecting has an id of "one", but when I try to make that the value of a variable and stick the variable in the code in it's placed, it doesn't work anymore. Is there a different way I can do this to make it work? Here is the code:
var temp2 = "one";
$(document).ready(function () {
$("#temp2").click(function () {
$("#temp2").animate({
"opacity": "0.15"
}, "slow");
});
});
$()expects a string as an argument (for selectors) and temp2 is a variable name (not a string).