Sorry would rather not add the site due to linkages being made.
Here is a code snippet of part of the menu:
<div class=”widget-1 widget-first footer-widget”><aside id=”nav_menu-3″ class=”widget widget_nav_menu”><ul id=”menu-footer-menu-2″ class=”menu”><li class=” menu-item-481″><a href=”https://www.mysite.com/ordering/”><i class=”icon-truck”></i><span>Ordering</span></a></li><li class=” menu-item-6920″><a href=”https://www.mysite.com/sustainable/”><span>Sustainability</span></a></li></ul>
and chatgpt scarily suggests this as a solution:
You can use JavaScript to search for a specific class, such as menu-item-6920
, and add a new class to an i
tag within that element. Here is an example of how you can do this:
JavaScript
This code is AI-generated. Review and use carefully. Visit our FAQ for more information.Copy
// Find the menu item with the class 'menu-item-6920'
var menuItem = document.querySelector('.menu-item-6920');
// Create a new 'i' element
var icon = document.createElement('i');
// Add the 'icon-class' class to the new 'i' element
icon.classList.add('icon-info');
// Insert the new 'i' element before the first child of the menu item's 'a' element
menuItem.querySelector('a').insertBefore(icon, menuItem.querySelector('a').firstChild);
This code finds the menu item with the class?menu-item-6920
, creates a new?i
?element, adds the?icon-class
?class to the new?i
?element, and inserts the new?i
?element before the first child of the menu item’s?a
?element. You can modify this code to target a different menu item or add a different class to the?i
?tag.
This works ??
I suppose what I’m then asking – is this the best work around for menu icons in the theme now?
Thanks