- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet_Element_By_className.html
More file actions
Latest commit
71 lines (66 loc) · 2.75 KB
/
Copy pathGet_Element_By_className.html
File metadata and controls
71 lines (66 loc) · 2.75 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
70
71
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8" />
<metaname="viewport" content="width=device-width, initial-scale=1.0" />
<title>🏴‍☠️ Complete Javascripts Course</title>
<linkhref="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
<style>
.highlight {
background-color: yellow;
}
</style>
</head>
<body>
<br/>
<br/>
<center>
<!-- <input type="text" id="item"> -->
<br/>
<divid="wrapper">📃 🏪 👾</div>
<br/>
<formname="myForm">
<inputtype="url" id="url" name="url" class="highlight" />
<inputtype="text" id="first" name="first" />
<inputtype="text" id="last" name="last" />
<br/><br/>
<textareaname="output" class="highlight" cols="100" rows="10"></textarea>
<br/><br/>
<divid="another">
Parent
<divid="one">Test 1</div>
<divid="two" class="highlight">Test 2</div>
<divid="three">Test 3</div>
<divid="four">Test 4</div>
<divid="five" class="highlight">Test 5</div>
<divid="six">Test 6</div>
<divid="seven">Test 7</div>
<divid="eight" class="highlight">Test 8</div>
</div>
<inputonclick="myFun1()" type="button" class="btn btn-outline-secondary" value="Click Here" id="btn1" />
</form>
</center>
<script>
varoutput=document.getElementById("wrapper");
// var divList = document.getElementsByTagName("div");
varhighlightList=document.getElementsByClassName("highlight");
// divList[7].innerHTML = "Welcome to my Website";
functionmyFun1(){
varhtml="<h1>Div List</h1>";
for(varx=0;x<highlightList.length;x++){
if(highlightList[x].innerText){
html+=highlightList[x].innerText+"<br>";
}elseif(highlightList[x].value){
html+=highlightList[x].value+"<br>";
}
}
output.innerHTML=html;
}
</script>
<scriptsrc="https://code.jquery.com/jquery-3.5.0.js"
integrity="sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc=" crossorigin="anonymous"></script>
<scriptsrc="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<scriptsrc="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
</body>
</html>