Check the jQuery FAQ…
You can use the length property of the jQuery collection returned by your selector:
if ( $('#myDiv').length ){}
More Related Contents:
- the value of the property “if” is null or undefined, not a Function object [closed]
- Converting a JS object to an array using jQuery
- Why is null an object and what’s the difference between null and undefined?
- jQuery document.createElement equivalent?
- How can I apply a jQuery function to all elements with the same ID?
- JavaScript: filter() for Objects
- When should I use jQuery’s document.ready function?
- How to get a DOM Element from a jQuery selector?
- Difference between HTMLCollection, NodeLists, and arrays of objects
- How do I create a link using javascript?
- How to show Page Loading div until the page has finished loading?
- What is difference between width, innerWidth and outerWidth, height, innerHeight and outerHeight in jQuery
- How to bind bootstrap popover on dynamic elements
- JavaScript equivalent of jQuery’s extend method
- How to find a parent with a known class in jQuery?
- jQuery count child elements
- JavaScript: DOM load events, execution sequence, and $(document).ready()
- How to move table row in jQuery?
- JavaScript scrollTo method does nothing?
- Select div using wildcard ID
- How can I convert a jQuery object to an Element?
- getElementById returning value only for first element [closed]
- querySelector vs. getElementById [closed]
- Storing a variable in the JavaScript ‘window’ object is a proper way to use that object?
- How to add DOM element script to head section?
- Delaying a jquery script until everything else has loaded
- User Activity Tracking using javascript library [closed]
- How to get on-screen visible element objects in jQuery? [duplicate]
- In web browsers, what’s the difference between onblur and onfocusout?
- Create a table in SVG