Skip to content

Instantly share code, notes, and snippets.

@OscarGodson
Created December 17, 2011 02:34
Show Gist options
  • Save OscarGodson/1488926 to your computer and use it in GitHub Desktop.
Save OscarGodson/1488926 to your computer and use it in GitHub Desktop.
/**
* Converts an input type to another specified because you aren't allowed for security
* reasons to change the type via JS attribute APIs.
* @param {string} type The type you want to convert it to
* @returns {object} A jQuery object of the new selected inputs it was replaced with
*/
$.fn.convertInputType = function(type){
return this.map(function(i, elem){
var clone = $( this ).clone().attr('type',type);
$(this).replaceWith(clone);
return clone[0];
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment