Using jQuery, is it possible to change all matched elements to a different type?
For example, can I select all a
tags, $(\"a\")
, and change
No, you can't actually change it, but you can replace them with a new element using the replaceWith() method:
$("a").replaceWith("");
If there are any attributes that you want to keep, you'll need to manually set them:
$("a").replaceWith(function() {
return $("", {
class: this.className,
value: this.innerHTML
});
});