I am trying to set a background color for an ID + Variable but I can’t figure it out. There must be something really small that I am not aware of.
Here is what I have:
var abc = $dialog.data( "url" );
alert(abc)
This Alerts: item1
var cde = '#' + abc
alert(cde)
This Alerts: #item1
So far so good. Now, I’m trying to change the background for that ID.
So:
This works:
$(body).css('background-color', 'black');
This doesn’t:
cde.css('background-color', 'black');
$(cde).css('background-color', 'black');
$("#" + abc).css('background-color', 'black');
All are in the same function.
What I’m I doing wrong?
Thanks a lot
The only reason I see that your code is not working is because the value that you pass to jQuery (namely cde or “#” + abc) is not of type “String”.
You can do some test for that :
If the type is not string, then you could simply do :