Hi there,
I’m trying to change the image source of the ‘Image with text’ element in Dawn 2.0 depending on the user tag.
Inspecting the site gave me the div id as “ImageWithText–template–21760167051540__66d333dc-1533-43ed-867a-28f688c0646a”
So I tried JavaScript code to target that element in theme-editor.js:
$(document).ready(function() {
var userTag = “{{ customer.tags }}”;
var image = document.getElementById(“ImageWithText–template–21760167051540__66d333dc-1533-43ed-867a-28f688c0646a”).getElementsByTagName(“img”)[0];
if (userTag == “AAA”) {
image.src=“https://cdn.pixabay.com/photo/2014/12/21/07/49/fireworks-574739_1280.jpg”;
} else if (userTag == “BBB”) {
image.src=“https://cdn.pixabay.com/photo/2016/12/03/15/44/fireworks-1880045_1280.jpg”;
}
});
But no dice. Does anyone know how I could achieve this?
Many thanks.