jQuery 判断是否包含某个属性
2024-08-23 08:19:07
1、Get the attribute, check the value
var attr = $(this).attr('name'); // For some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
if (typeof attr !== typeof undefined && attr !== false) {
// Element has this attribute
}
2、Native JavaScript has a way
$(this)[0].hasAttribute("name"); jQObject[0].hasAttribute("name");
3、Filter the selection
$(this).is('[name]'); $(this).filter("[name='choice']");
最新文章
- IntelliJ IDEA14.1中java项目Maven中没有配置JDK时的问题
- ios Unit test 入门书籍推荐
- 转载 Servlet3.0中使用注解配置Servle
- JS运动基础(三) 弹性运动
- 浏览器对象模型(BOM,Browser Object Model)
- QTP获取系统时间并自定义格式
- iOS xcode8提交 iOS10 “此构建版本无效” (已解决)
- 【Android Studio使用教程 7】AndroidStudio问题汇总
- Linux3.4内核的基本配置和编译
- 获取不变的UDID-b
- linux中ctrl+z、ctrl+d和ctrl+c的区别
- Android dialog 问题
- spring整合redis客户端及缓存接口设计(转)
- hdoj 1506&;amp;&;amp;1505(City Game) dp
- easyUI日期框返回到月份,选择日期也只到月份
- 海量数据挖掘MMDS week4: 推荐系统之隐语义模型latent semantic analysis
- mvc路由报错
- bootstrap学习: 折叠插件和面板
- Approx Analytic Arealight
- centos7 tomcat9
热门文章
- 1 background(复合属性)与font(复合属性) 2 行内块的间距问题 3 行内元素的margin 4 清除浮动 5定位的元素的层级 6 Border-radius: 边框半径
- mac远程桌面连接windows 8.1 update,提示: 远程桌面连接无法验证您希望连接的计算机的身份
- 如何在.NET上处理二维码
- 女生的最爱,装饰品。WPF也有,Adorner。(上海晒衣服理念)
- C#开发EyeLink眼动仪的实验程序
- JavaScript实现TwoQueues缓存模型
- [Unity3D]自己动手重制坦克舰队ArmadaTank(2)从碰撞说起
- Castle中AdditionalInterfaces用法介绍
- Android开发学习之路-图片颜色获取器开发(1)
- The currently selected variant ";arm-debug"; uses split APKs, but none of the 1 split apks are compatible with the current device with density ";213"; and ABIs ";x86";.