<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>matches Example</title>
</head>
<body>
<div class="example" id="test">This is a test element</div>
<button onclick="checkMatch()">Check Match</button>
<script>
function checkMatch() {
const element = document.getElementById('test');
if (element.matches('.example')) {
element.style.color = 'red';
element.textContent = "Element matches the selector!";
}
}
</script>
</body>
</html>