My website is built on prestashop, and I have a dropdown menu with various clickable categories. However, I want to remove the links from the "Marques" and "Les Gammes" categories and only keep the text displayed. To achieve this, I am using the each()
function to target all the categories. The issue I am facing is that it returns an array within the li
and the nested ul
inside the li
.
If you'd like to see the code in action, check out this JSFiddle link.
Below is the JavaScript code snippet:
$('jms-mega-menu').ready(function () {
// Target each div
$('.notlink').each(function () {
// Get the content
var str = $(this).text();
$(this).html(str);
});
});
Here is a snippet of the HTML code structure. For the complete code, please refer to the JSFiddle link.
<ul jms-mega-menu>
<div>
...
<ul class="mega-nav level1">
<li class=" haschild group notlink"><a id="item-8" href="#">Marques</a>
<ul>
<li><a id="item-9" href="#">Apple</a></li>
<li><a id="item-10" href="#">Samsung</a></li>
</ul>
</li>
</ul>
<ul>
...