使用jQuery检查该元素是否在DOM中? [英] Check that element is in DOM or not with jQuery?

查看:62
本文介绍了使用jQuery检查该元素是否在DOM中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有快速简单的问题。如何检查元素是否在DOM中?



例如,如何检查是否有

< p id =did_i_really_exist_or>这只是矩阵< / p>

解决方案

p $ p> if($(#do_i_really_exist_or)。length){
// - 它确实存在。
}


I have quick and simple question. How can I check that an element is in the DOM or not?

For example how can I check if there is
<p id="does_i_really_exist_or">this is just matrix</p>

解决方案

if ( $("#does_i_really_exist_or").length ) {
   //-- It does exist.
}

这篇关于使用jQuery检查该元素是否在DOM中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆