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

More available Categories:-

Responses


 (Getemail alerts when others member replies)







When two partners always agree, one of them is not necessary." If there is some point you haven't thought about, be thankful if it is brought to your attention.
-Dale Carnegie