I am passing an id into a function as a string. I want to use that ID to then change the background color. I have used:
$("#"+address).css("background-color", "#3399FF");
but it is not changing the background color and when I do a:
console.log($("#"+address).css("background-color"));
It is coming up as undefined.
How can I pass the variable address into jquery?
Thanks for your help.
Kevin
I’m going to take a stab in the dark here,
You say you are using and address as an id
by appending a #,
The jquery selector becomes, find the element with ID 1234, then any children of type Any, then any children of type st with class ”.
Which looks like
You need to escape spaces, periods, hell everything here !”#$%&'()*+,./:;<=>?@[]^`{|}~
As per the specification, an id should
So to escape a valid id use,
as per HERE