###Element.matches()
Element.matches()
element.matches(selectorString)
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>
###Element.matches()
element.matches(selectorString)
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>
Element.matches()
element.matches(selectorString)
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>
###Element.matches()
element.matches(selectorString)
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>
###Element.matches()
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>
###Element.matches()
element.matches(selectorString)
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>
###Element.matches()
According to MDN Web Docs:
The
Element.matches()method returnstrueif the element would be selected by the specified selector string; otherwise, returnsfalse.
Therefore, you can use Element.matches() to determine if an element contains a class.
const element = document.querySelector('#example');
console.log(element.matches('.foo')); // true
<div id="example" class="foo bar"></div>