Skip to content

Commit 1811caf

Browse files
committed
update color code
1 parent 90a4cbe commit 1811caf

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

Example/Array/Example.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
<script>
8+
9+
data = ['A','B','C','D'];
10+
11+
//console.log(data[0]);
12+
13+
for(let i = 0 ; i <= 10 ; i++){
14+
console.log(data[i])
15+
}
16+
17+
18+
</script>
19+
</head>
20+
<body>
21+
22+
</body>
23+
</html>

Example/Loop/Color.html

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>
7+
How to Change Background Color
8+
of a Div on Mouse Move Over
9+
using JavaScript ?
10+
</title>
11+
12+
<style>
13+
li{
14+
list-style: none;
15+
border: solid 1px black;
16+
height: 25px;
17+
width: 25px;
18+
border-radius: 100px;
19+
text-align: center;
20+
float: left;
21+
padding: 25px;
22+
margin: 5px;
23+
background-color: aqua;
24+
}
25+
</style>
26+
</head>
27+
28+
<body>
29+
30+
31+
<lable>Enter Number : </lable>
32+
<input type="text" id="box_no">
33+
<button onclick="changeColor()">Result</button>
34+
35+
<ul id="print">
36+
</ul>
37+
38+
<script type="text/javascript">
39+
40+
41+
const hexCharacters = [0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F"]
42+
43+
44+
45+
function getCharacter(index) {
46+
return hexCharacters[index]
47+
}
48+
49+
function generateNewColor() {
50+
let hexColorRep = "#"
51+
52+
for (let index = 0; index < 6; index++){
53+
const randomPosition = Math.floor ( Math.random() * hexCharacters.length )
54+
hexColorRep += getCharacter( randomPosition )
55+
}
56+
57+
return hexColorRep
58+
}
59+
60+
61+
62+
function changeColor(){
63+
64+
// let color_box = document.getElementById("box");
65+
66+
// for(let i = 0 ; i < 10 ; i++){
67+
68+
// // let color = document.getElementById("box").style.backgroundColor = generateNewColor();
69+
// color_box.innerHTML += "<li>"+generateNewColor()+"</li>";
70+
71+
72+
// }
73+
list = document.getElementById("box_no").value;
74+
75+
let print_data = document.getElementById("print");
76+
77+
for(let i = 0; i <= list ; i++){
78+
79+
80+
// print_data.style.backgroundColor += generateNewColor();
81+
print_data.innerHTML += "<li>"+i+"</li>";
82+
83+
84+
85+
86+
87+
//
88+
89+
90+
91+
}
92+
}
93+
94+
</script>
95+
96+
</ul>
97+
98+
99+
</body>
100+
101+
</html>

0 commit comments

Comments
 (0)