I'm trying to add icon in my Shopify menu like this :
The menu I want with icons before titles
The only way I found for adding icon to Shopify header menu is to use Jquery. So I added Jquery script to my theme.liquid and I've followed the steps in this video but the script won't work.
Here's the script :
<script>
$('#HeaderMenu-fleurz').text(function(){
var navText = $(this).text();
$(this).prepend('<img scr="https://cdn.shopify.com/s/files/1/0782/7714/9020/files/flower-tulip.png?v=1696549391"/>');
}
});
</script>
And here's the inspector on the item :
My Shopify website now
Sorry I'm not an English native, and thanks a lot for your help !
I tried some homemade script but I'm not js dev, nor dev at all so nothing would work ?
Explanation
Hi, it'll be good if you could post your html code together, so we can understand your issue better. I guess you are trying to prepend the element into the menu header
Code
<script>
var imgsrc = $("<img>").attr("src", "https://cdn.shopify.com/s/files/1/0782/7714/9020/files/flower-tulip.png?v=1696549391")
$('#HeaderMenu-fleurz').prepend(imgsrc);
</script>
December 30, 2023
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand
December 30, 2023