<!DOCTYPE html>
<html>
<style>
.container {
background-color: tomato;
color: white;
padding: 20px;
}
</style>
<body>
<h1>The Element Object</h1>
<h2>The closest() Method</h2>
<p id="demo" class="container"></p>
<script>
const element = document.getElementById("demo");
let text;
if (element.closest(".container, .wrapper")) {
text = "This element is closest to one of the selectors.";
} else {
text = "This element does not match any of the selectors.";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>