Frontend Development

Stupid JS problem (still learning this)

Submitted by AAA, , Thread ID: 21709

Thread Closed
AAA
Offline
Level:
0
Reputation:
73
Posts:
834
Likes:
110
Credits:
582
10-06-2016, 09:33 PM
#1
So I have this stupid javascript problem, and I need some help!


Code:
<!DOCTYPE html>
<html>
<head>
  <title>mahh...</title>
  <meta charset="UTF-8">
  <style> #p {font-size:30px;} </style>
</head>

<body>

<p>Choose your favorite color:</p>

<form>
<select id="select" onchange="foo()">
  <option>Colors</option>
  <option value="red">RED</option>
  <option value="blue">BLUE</option>
  <option value="green">GEEEN</option>
  
</select>
</form>


<p id="p"></p>

<script>
function foo() {
    var color = document.getElementById("select").value;
    document.getElementById("p").innerHTML = "Your favorite color is: " + color;
}

</script>

</body>
</html>

How to have body background same as selected color ?

E.g. If you select the red color, body background should be red...


Fucking DOM!
[Image: XhhKTdF.png]
1

Users browsing this thread: 1 Guest(s)