问题:
Possible Duplicate: 可能重复:
Check existence of an attribute with JQuery 使用JQuery检查属性是否存在
How do you check if there is an attribute on an element in jQuery? 你如何检查jQuery中的元素是否有属性? Similar to hasClass
, but with attr
? 与hasClass
类似,但是attr
?
For example, 例如,
if ($(this).hasAttr("name")) {
// ...
}
解决方案:
参考一: https://stackoom.com/question/5WtI/jQuery-hasAttr检查元素是否有属性-重复参考二: https://oldbug.net/q/5WtI/jQuery-hasAttr-checking-to-see-if-there-is-an-attribute-on-an-element-duplicate
来源:oschina
链接:https://my.oschina.net/u/4432649/blog/4348715