Skip to content

Instantly share code, notes, and snippets.

@ycmjason
Created September 4, 2016 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycmjason/04e84efd568531e83771c47a71b238cf to your computer and use it in GitHub Desktop.
Save ycmjason/04e84efd568531e83771c47a71b238cf to your computer and use it in GitHub Desktop.
Temporarily replace a css property of an element and restore that after fn is called.
function tempCSS(element, stylename, temp_value, fn){
// Temporarily replace a css property and restore it after fn();
var ret;
var original_value = element.css(stylename);
element.css(stylename, temp_value);
ret = fn();
element.css(stylename, original_value);
return ret;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment