Skip to content

Instantly share code, notes, and snippets.

@DDtMM
DDtMM / changeElementType.js
Last active December 19, 2015 22:49 — forked from etienned/changeElementType.js
This version chains, returning a jquery object with updated children.
(function ($) {
$.fn.changeElementType = function (newType) {
var attrs, elem, $elem;
for (var i = 0, il = this.length; i < il; i++) {
attrs = {};
$elem = $(elem = this[i]);
$.each(elem.attributes, function (index, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});