Created
July 27, 2014 08:40
-
-
Save hehongwei44/b4192af8227d756bfda6 to your computer and use it in GitHub Desktop.
使用cssdisplay属性来切换元素可见性的一组函数
This file contains 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
/*使用cssdisplay属性来切换元素可见性的一组函数*/ | |
/** | |
* 使用display来隐藏元素的函数 | |
* */ | |
function hide(elem) { | |
var curDisplay = getStyle(elem, 'display'); | |
if (curDisplay != 'none') { | |
elem.$oldDisplay = curDisplay; | |
} | |
elem.style.display = 'none'; | |
} | |
/** | |
* 使用display来显示元素的函数 | |
* */ | |
function show(elem) { | |
elem.style.display = elem.$oldDisplay || ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment