I am working with a jQuery accordion and have a specific need to remove the href attribute from the parent li element without affecting its children. This task requires precision in targeting only the parent li.
var parent = $("#quicklaunch ul > li:has('ul')");
parent.find("span.menu-item-text:first").append(" <i class='fa fa-angle-down' aria-hidden='true'></i>");
parent.find("a:first").removeAttr("href").css("cursor", "pointer");
The current code successfully removes the link, but it has a limitation where if the parent li does not have a link, it proceeds to work on the children elements. I want the link within the parent li to remain untouched. What selector should I use to achieve this?
EDIT TO ADD: I managed to use has("a"), however, I encountered an issue with the removeAttr selector...