I'm trying to have an anchor tag removed and replaced with a span tag but keep the class attr. I have this code but it is showing "undefined" for the class.
$("#wprmenu_menu").find('li:has(ul) > a').replaceWith(function() {
var Qthis = $(this);
var className = Qthis.attr('class');
return $("<span class=\"" + className + "\">" + Qthis.html() + "</span>");
});
the anchor tag gets removed, and the text inside stays but the class does not transfer over.