The following almost works in replace all instances of span[data-type=\"yesno\"] with lis, but I\'d like to also preserve the attributes, classes, etc. Is there
span[data-type=\"yesno\"]
You have to loop on your element attributes :
$('span[data-type="yesno"]').replaceWith(function(){ $li = $("", {html: $(this).html()}); $.each(this.attributes, function(i, attribute){ $li.attr(attribute.name, attribute.value); }); return $li; })