-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuerySelectorAll_Element_Selector.html
More file actions
69 lines (63 loc) · 2.44 KB
/
QuerySelectorAll_Element_Selector.html
File metadata and controls
69 lines (63 loc) · 2.44 KB
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
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>🏴‍☠️ Complete Javascripts Course</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
<style>
div .output {
background-color: red;
}
</style>
</head>
<body>
<br />
<br />
<center>
<!-- <input type="text" id="item"> -->
<br />
<div id="wrapper">📃 🏪 👾</div>
<br />
<div id="message">Message 1</div>
<div id="message1">Message 2</div>
<div id="message">Message 1</div>
<div class="output">Test Me 1</div>
<div class="output">Test Me 2</div>
<div id="pickme1">
<div class="output highlight">Test Me 3</div>
</div>
<input type="text" name="queryStuff" id="queryStuff">
<input type="button" class="btn btn-outline-warning" onclick="mySel()" value="Get Query">
<div id="pickme2">
<div class="output">Test Me 4</div>
<div class="output">Test Me 5</div>
<div class="output">Test Me 6</div>
</div>
<div class="output highlight">Test Me 7</div>
<div class="output">Test Me 8</div>
<div class="output">Test Me 9</div>
<div class="output">Test Me 10</div>
</center>
<script>
var el = document.querySelectorAll("div .output");
function mySel() {
var a = document.getElementById('queryStuff').value;
var el = qs(a);
var html = "Results<br>";
for (var x = 0; x < el.length; x++) {
html += el[x].innerText + "<br>";
}
document.getElementById('message').innerHTML = html;
}
function qs(el) {
return document.querySelectorAll(el);
}
</script>
<script src="https://code.jquery.com/jquery-3.5.0.js"
integrity="sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
</body>
</html>