2024-04-12 11:29:46 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div class="demo container"> Grandparent
|
|
|
|
<div class="demo container">Parent
|
|
|
|
<div id="myElement" class="demo">The outer HTML of closest element will be shown.</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var element = document.getElementById("myElement");
|
2024-05-06 15:22:16 -04:00
|
|
|
var closes2 = element.closest("div.container");
|
2024-04-12 11:29:46 -04:00
|
|
|
|
|
|
|
console.error('element.closest.html');
|
2024-05-08 09:57:56 -04:00
|
|
|
console.assert(closes2 != null, 'not null');
|
2024-05-05 15:52:07 -04:00
|
|
|
|
2024-05-06 15:22:16 -04:00
|
|
|
closes2 = element.closest("p.test");
|
|
|
|
console.assert(closes2 === null, 'NULL');
|
2024-05-05 15:52:07 -04:00
|
|
|
|
2024-06-01 07:30:03 -04:00
|
|
|
console.exit();
|
2024-04-12 11:29:46 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|