Skip to content

Instantly share code, notes, and snippets.

@hehongwei44
Created July 22, 2014 02:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hehongwei44/fb9789ef08a2ef9c7ec3 to your computer and use it in GitHub Desktop.
检查元素是否有一个指定的特性
/*检查元素是否有一个指定的特性*/
function hasAttribute(elem, name) {
// !!表达式快速的求bool值
return !!elem.getAttribute(name);
}
@hehongwei44
Copy link
Author

!!将一个值方便快速转化为布尔值 比如 !!window===true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment