1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/test/ecmascript/closest.html

21 lines
396 B
HTML
Raw Normal View History

2021-12-01 10:36:01 -05:00
<!DOCTYPE html>
<html>
<body>
2021-12-17 08:12:44 -05:00
<div class="demo container"> Grandparent
2021-12-01 10:36:01 -05:00
<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>