1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-02 08:57:19 -04:00
elinks/test/ecmascript/closest.html
2021-12-17 14:12:44 +01:00

21 lines
396 B
HTML

<!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");
var closest = element.closest(".container");
if (closest) {
alert(closest.outerHTML);
}
</script>
</body>
</html>