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:-








There's no benchmark for how life's "supposed" to happen. There is no ideal world for you to wait around for. The world is always just what it is now, it's up to you how you respond to it.
-Isaac Marion Warm Bodies