Skip to content

Instantly share code, notes, and snippets.

@abombss
Created June 15, 2011 07:28
Show Gist options
  • Save abombss/1026643 to your computer and use it in GitHub Desktop.
Save abombss/1026643 to your computer and use it in GitHub Desktop.
JQuery plugin to fix the html <button> issue when submitting forms in IE <= 7
(function ($) {
/// <param name="$" type="jQuery">JQuery</param>
$.fn.iebuttonfix = function() {
return $(this).each( function() {
var $f = $(this);
if ($f.prop("nodeName").toLowerCase() === "form") {
$f.submit(function() {
$("button", $f).each(function() {
var $b = $(this);
if ($b.data("ie.btnfix.clicked")) {
$b.html($b.val());
} else {
$b.prop('disabled', true);
}
})
});
$("button", $f).click(function() {
$(this).data("ie.btnfix.clicked", true);
});
}
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment