我有一个快速简单的问题。如何检查元素是否在DOM中?
例如,我该如何检查是否存在以下内容:
例如,我该如何检查是否存在以下内容:
<p id="does_i_really_exist_or">this is just matrix</p>
if ( $("#does_i_really_exist_or").length ) {
//-- It does exist.
}
if ($("#does_i_really_exist_or").length > 0) {
// do something
}
if ($("#does_i_really_exist_or").length > 0) {
// do something
}
if ($("#does_i_really_exist_or").size() > 0) {
// do something
}
if ($("#does_i_really_exist_or")[0]) {
// do something
}