Skip to content

Instantly share code, notes, and snippets.

@hehongwei44
Created July 27, 2014 08:40
Show Gist options
  • Save hehongwei44/b4192af8227d756bfda6 to your computer and use it in GitHub Desktop.
Save hehongwei44/b4192af8227d756bfda6 to your computer and use it in GitHub Desktop.
使用cssdisplay属性来切换元素可见性的一组函数
/*使用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