jQuery 判断控件ID是否存在

转自 http://blog.tianya.cn/blogger/post_read.asp?BlogID=3578591&PostID=35749482

JS
  if(document.getElementById("id")){
   alert("存在");
  } 
  else {
   alert("不存在");
  }


Jquery


  if(jQuery("#id").length > 0){
   alert("存在");
  }
  else{
   alert("不存在");
  }
  或者用size也行

posted @ 2012-12-24 16:58  kumat  阅读(1153)  评论(0)    收藏  举报