jQuery not working with variable. the issue is with this line:
$('img[alt = id]').trigger("click");
if I change it to
$('img[alt = "6"]').trigger("click");
Everything works as expected. I just can't workout how to use a variable instead of a value within the quotes. I have tried putting id in single / double quotes with no luck. I'm sure it will be something obvious. Can anyone help.
This is the full code.
$(window).load(function () {
// run code
// $('img[alt ="6"]').trigger("click");
var id = localStorage.getItem("CustomerID");
$('img[alt = id]').trigger("click");
// window.alert(id);
});