JSFiddle - React, Tailwind, and code Playground

by joshcomley

HTML

<input type="submit" name="josh" class="test" />

JavaScript

(function($){
  $.fn.changeType = function( type ) {  
    return this.each(function(i, elm) {
        var newElm = $("<input type=\""+type+"\" />");
        for(var iAttr = 0; iAttr < elm.attributes.length; iAttr++) {
            var attribute = elm.attributes[iAttr].name;
            if(attribute === "type") {
                continue;
            }
            newElm.attr(attribute, elm.attributes[iAttr].value);
        }
        $(elm).replaceWith(newElm);
    });
  };
})(jQuery);

$("input").changeType ("checkbox");

$("input.test").change(function(){
    alert(1);
});