检查元素是否有一个指定的特性
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
/*检查元素是否有一个指定的特性*/ | |
function hasAttribute(elem, name) { | |
// !!表达式快速的求bool值 | |
return !!elem.getAttribute(name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!!将一个值方便快速转化为布尔值 比如 !!window===true