i try to add a variable to the jquery selector to add a css class in leaflet.
var abc = $(TEST._icon);
abc.addClass('pulse');
or
$(TEST._icon).addClass('pulse');
works good. now i want a variable for TEST – so i try following without success:
var abc = "TEST";
$(abc + "._icon").addClass('pulse');
can anybody help?
thank you!
If
TEST
is a global variable,$(window[abc] + "._icon")
. If it’s a local variable, you can’t access it dynamically.thank you – i have try it out. dont work… the error message is: Internal error. Error Message: Syntax error, unrecognized expression: [object Object]._icon,
Sorry, I got confused about what you’re doing. It should be
$(window[abc]._icon)
. You don’t need concatenation.