jquery 检测元素是否存在的实例代码

if ($('#myDiv).length) { 
    // your code 
}

 Simple, but not obvious.

本文转自网络,如有侵权请联系客服删除。