Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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);
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.