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)







Make a pact with yourself today to not be defined by your past. Sometimes the greatest thing to come out of all your hard work isn't what you get for it, but what you become for it. Shake things up today! Be You...Be Free...Share.
-Steve Maraboli Life the Truth and Being Free