如何在DOM中检查htmlElement对象
这个问题在这里已经有了答案:
您可以检查DOM是否包含htmlElement
if ($.contains(document, $(htmlElement)){
// htmlElement is attached to the DOM
}
为了给出适当的条件,你总是需要检查物体的长度
即if($(“li.k-button.k-state-hover”)。length)
试用javascript:
var ele = document.getElementById('yourId');
or
var ele = document.getElementByTagName('tag name');
if (typeof(ele) != 'undefined' && ele != null)
{
// exists.
}
链接地址: http://www.djcxy.com/p/14693.html