# Checking elements in JavaScript

`matches` `contains`

Given an element:

`<div id="elem" class="www"></div>`

Check if this element is an element with `www` class.

Given an element. Check if this element is a paragraph.

Given two variables `elem1` and `elem2` containing two elements:

`<div id="elem1"> <p id="elem2"></p> </div>` `let elem1 = document.querySelector('#elem1'); let elem2 = document.querySelector('#elem2');`

Check if an element from `elem2` is a child of an element from `elem1`.

← →
↑
en ru