判断对象是否为空 js与Jquery区别

1. js

if(document.getElementById('id')==null)

2 Jqurey

if($('#id').length==0)

注意:不可用$('#id')==null判断,因为$('#id')总是返回JQuery对象