-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
63 lines (49 loc) · 1.32 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test of jquery.deepest.js</title>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<script src="jquery.deepest.js"></script>
<script>
function escape(htmlStr) {
return htmlStr.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
$(function() {
// looking for any deepest element in #test1
let $test1deepest = $("#test1").deepest();
$("#result1").html('Deepest element of <b>#test1</b> DOM tree is: <b>' + escape($test1deepest.get()[0].outerHTML) + '</b>');
// looking for any deepest element in #test1
let $test2deepest = $("#test2").deepest('span');
$("#result2").html('Deepest element of <b>#test2</b> DOM tree is: <b>' + escape($test2deepest.get()[0].outerHTML) + '</b>');
});
</script>
<style>
#test1, #test2 {
display: none;
}
</style>
</head>
<body>
<div id="test1">
<div class="level1">
<div class="level2">
<div class="level3"></div>
</div>
</div>
</div>
<div id="test2">
<ul>
<li><a href="#">link1</a></li>
<li><a href="#">link2<span></span></a></li>
<li><a href="#">link3</a></li>
</ul>
</div>
<div id="result1"></div>
<div id="result2"></div>
</body>
</html>