How to check an element is exist in a form using JQuery or not?

Options :
  1. if (#("myControlId")){
      // your logic goes here
    }
    
  2. if ($("#myControlId").exists){
      // your logic goes here
    }
    
  3. if ($("#myControlId")){
      // your logic goes here
    }
    
  4. if (exists("#myControlId")){
      // your logic goes here
    }
    
Answer and Explanation :-

Answer: Option 3

Explanation:

You can use check the element is exists or not using simple if statement and the control id of an element for eg

if ($("#myControlId")){
  // your logic goes here
}

How do you rate this queston?  Very Easy  Easy  Average  Above Average  Tough

Previous Question : How to remove css class using JQuery?

Click here for online test on JQuery

Responses


 (Getemail alerts when others member replies)

More available Categories:-








It is true. Indeed, that is why I dared not speak. I have yearned to be again at the side of my beloved Arianllyn, and my thoughts are with her now. But had I chosen to return, I would ever wonder whether my choice was made through wisdom or following the wishes of my own heart. I see this is as it must be, and the destiny laid upon me. I am content to die here.
-Lloyd Alexander The Black Cauldron