You should use Node.contains
, since it’s now standard and available in all browsers.
https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
More Related Contents:
- How do I check if an element is hidden in jQuery?
- Why does jQuery or a DOM method such as getElementById not find the element?
- How do I set/unset a cookie with jQuery?
- jQuery .live() vs .on() method for adding a click event after loading dynamic html
- Creating a new DOM element from an HTML string using built-in DOM methods or Prototype
- Executing elements inserted with .innerHTML
- How can I select an element by name with jQuery?
- Difference between innerText, innerHTML and value?
- getElementsByTagName() equivalent for textNodes
- Event handlers inside a Javascript loop – need a closure?
- document.createElement(“script”) synchronously
- jQuery object and DOM element
- Javascript get XPath of a node
- How to resolve the C:\fakepath?
- How can I get the DOM element which contains the current selection?
- Difference between DOM parentNode and parentElement
- How to access component methods from “outside” in ReactJS?
- How do I serialize a DOM to XML text, using JavaScript, in a cross browser way?
- How do you set the document title in React?
- Can I change an HTML element’s type?
- “Cut and Paste” – moving nodes in the DOM with Javascript
- Remove specific HTML tag with its content from javascript string
- Is it possible to programmatically catch all events on the page in the browser?
- how to compare two elements in jquery [duplicate]
- Is there any way to accelerate the mousemove event?
- How do I wrap a text selection from window.getSelection().getRangeAt(0) with an html tag?
- Inject CSS stylesheet as string using Javascript
- JavaScript: Is it better to use innerHTML or (lots of) createElement calls to add a complex div structure? [duplicate]
- Getting the text from a drop-down box
- Accessing a DOM object defined in an external SVG file