Created
September 4, 2016 21:40
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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