jquery Determines whether an object is empty and traverses a simple instance of the object


javascript:

if(document.getElementById("target_obj_id")){

} else {

}

jquery:

This does not work because $(”# target_obj_id”) returns object regardless of whether the object exists or not

1.
 var target_obj = jQuery('#target_obj_id');
  if (target_obj.length > 0) { // If greater than 0  Identification  id  For target_obj_id The object of exists, otherwise it does not exist

  } else {

  }

2 ,
 if (target_obj[0]) {

  } else {

 }

3. $.isEmptyObject({}) // true
  $.isEmptyObject({ foo: "bar" }) // false

// Judge and traverse each object
if($("#t_specialsearch select").length <= 0){
          alert(" Object is empty ");
}else{
    //console.log($("#t_specialsearch select")[0]);
    $("#t_specialsearch select").each(function(){
      //alert($(this));
      console.log($(this));
    });

    for(var i in $("#t_specialsearch select")){
      console.log($("#t_specialsearch select")[i]);
    }
}

1 step 1 footprint, convenient for their own review, the shot when the shot, there are mistakes, 1 must correct, thank you very much, common progress!