-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
62 lines (44 loc) · 2.07 KB
/
script.js
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
var x = 0;
var array = Array();
function input() {
array[x] = document.getElementById("inputid").value;
x++;
document.getElementById("inputid").value = "";
var names = document.getElementsByClassName('names');
color();
namelist();
function namelist() {
// document.getElementById('Result').innerText = `aaaaaaa`;
var result = "Your Entered Names are as follow <br>";
for (var y = 0; y < array.length; y++) {
result += [y + 1 + '.'] + ' ' + array[y] + '<br>';
}
document.getElementById("namelist").innerHTML = `${result}`;
}
function color() {
let container = document.querySelectorAll('body');//to change body color
// let container = document.querySelectorAll('div.container'); //to change content background color
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
container.forEach(function (odd) {
odd.style.background = "rgba(" + r + "," + g + "," + b + ",1)";
// odd.style.color = "rgb(" + r + "," + b + "," + g + ")";
});
}
}
function randomname() {
let show = array[Math.floor(Math.random() * array.length)];
let displayblock = document.getElementById('random');
displayblock.style.display = "block";
document.getElementById('random').innerHTML = `We got a random name -->>>>` + '<span>' + show + '</span>';
let container = document.querySelectorAll('body');
// let container = document.querySelectorAll('div#random');
// let container = document.querySelectorAll('div.container');
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
container.forEach(function (odd) {
odd.style.background = "rgba(" + r + "," + g + "," + b + ",1)";
});
}