Skip to content

Instantly share code, notes, and snippets.

@guillaumegarcia13
Created November 25, 2018 22:18
Show Gist options
  • Save guillaumegarcia13/3ee68259327a9072e056d556b07539fd to your computer and use it in GitHub Desktop.
Save guillaumegarcia13/3ee68259327a9072e056d556b07539fd to your computer and use it in GitHub Desktop.
Wrapping and masking a button with jQuery
$('input#checkout').wrap('<div id="bf"><div>');
var $cloneInput = $('input#checkout').clone();
$cloneInput
.attr('id', 'bf_checkout')
.attr('name', 'bf_checkout')
.appendTo('div#bf')
.on('click', function(e) {
doSomething().always(function() {
$('input#checkout').click(); // call underlying button
});
});
$('input#checkout').hide();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment