Create a gist now

Instantly share code, notes, and snippets.

jQuery Sandbox
$.fn.sandbox = function(fn) {
var element = $(this).clone(), result;
// make the element take space in the page but invisible
element.css({visibility: 'hidden', display: 'block'}).insertAfter(this);
// to override any display: none !important you may have been using
element.attr('style', element.attr('style').replace('block', 'block !important'));
result = fn.apply(element);
element.remove();
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment