How to check htmlElement object exists in DOM
This question already has an answer here:
您可以检查DOM是否包含htmlElement
if ($.contains(document, $(htmlElement)){
// htmlElement is attached to the DOM
}
In order to give proper condition you always need to check length of object
ie 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/14694.html
上一篇: 按值设置选择选项'selected'