jQuery hasAttr检查元素是否有属性[重复]

我是研究僧i 提交于 2020-08-11 20:48:18

问题:

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!