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

in cn •  6 years ago 
  1. js
    if(document.getElementById('id')==null)

2 Jqurey

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

     注意:不可用$('#id')==null判断,因为$('#id')总是返回JQuery对象
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

受教

Congratulations @fkoryp! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the number of posts published
Award for the number of comments

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!