当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 | if ($( '#myElement' ).length > 0) {
document.write( "id 为 myElement 元素存在" );
} else {
document.write( "id 为 myElement 元素不存在" );
}
document.write( "<br>" );
if ($( '#xxx' ).length > 0) {
document.write( "id 为 xxx 元素存在" );
} else {
document.write( "id 为 xxx 元素不存在" );
}
|
结果:
1 2 | id 为 myElement 元素存在
id 为 xxx 元素不存在
|
相关推荐:js教程
以上就是jquery怎么判断id是否存在的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
vue中jQuery怎么用
jQuery如何实现禁用浏览器后退
关于css中的id选择器与class选择器的介绍
jQuery如何让按钮不可用
如何用jQuery实现随机数
jQuery的作用是什么?
jQuery ui datepicker时间控件的用法(二)
jQuery怎么实现淡入淡出效果
jQuery如何判断是否点击按钮
jQuery对象与dom对象的区别有哪些?
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jquery怎么判断id是否存在