Created
August 25, 2016 17:14
-
-
Save ABM-Dan/e1ab4aca1e4cfe5809e1cd3a672f740f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
return $.fn.resetInput = function(callback) { | |
return this.each(function() { | |
var $el, type; | |
$el = $(this); | |
type = this.type; | |
switch (type) { | |
case 'select-one': | |
case 'select-multiple': | |
$el.find('option').each(function() { | |
return this.selected = this.defaultSelected; | |
}); | |
break; | |
case 'checkbox': | |
case 'radio': | |
this.checked = this.defaultChecked; | |
break; | |
default: | |
this.value = this.defaultValue; | |
} | |
if (typeof callback === 'function') { | |
return callback.call(this); | |
} | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment