Skip to content

Instantly share code, notes, and snippets.

View feldsam's full-sized avatar

Kristian Feldsam feldsam

View GitHub Profile
@feldsam
feldsam / jquery.type.js
Created June 6, 2012 11:06 — forked from johnboxall/jquery.type.js
For when you _really_ wanna change the type of a input with jQuery
var rtype = /^(?:button|input)$/i;
jQuery.attrHooks.type.set = function(elem, value) {
// We can't allow the type property to be changed (since it causes problems in IE)
if (rtype.test(elem.nodeName) && elem.parentNode) {
// jQuery.error( "type property can't be changed" );
// JB: Or ... can it!?
var $el = $(elem);
var insertionFn = 'after';