Change matching tag to another tag (div to a)
by Ian Roberts
HTML
<b class="b" style="cursor: default; ">Typeface.</b>
CSS
p {font-size:48px;font-weight:100;font-family:sans-serif;}
JavaScript
(function($) {
$.fn.changeTag = function(newType) {
var attrs = {};
$.each(this[0].attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});
this.replaceWith(function() {
return $("<" + newType + "/>", attrs).append($(this).contents());
});
}
})(jQuery);
$(".b").changeTag("p");