Browse Source

06 js css change

master
Jakub Škrabánek 7 months ago
parent
commit
7bc6b23023
  1. 37
      06/index.html
  2. 26
      06/script.js
  3. 0
      06/style.css

37
06/index.html

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS DOM stylizace</title>
<link href="https://fonts.googleapis.com/css2?family=Climate+Crisis&family=Oswald:wght@200..700&display=swap" rel="stylesheet">
</head>
<body>
<h1>JS DOM Stylizace</h1>
<p id="ltext">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam, aperiam itaque officia natus, beatae ut exercitationem ab voluptatum veniam maxime deserunt at est. Error possimus itaque quis aliquam saepe. Veniam!</p>
<br>
<select name="scolor" id="scolor" onchange="changeScolor()">
<option value="black">černá</option>
<option value="red">červená</option>
<option value="green">zelená</option>
<option value="blue">modrá</option>
<option value="purple">fialová</option>
</select>
<select name="sfont" id="sfont" onchange="changeSfont()">
<option value="Arial">Arial</option>
<option value="Courier New">Courier New</option>
<option value="Brush Script MT">Brush Script MT</option>
<option value="Climate Crisis">Climate Crisis</option>
<option value="Oswald">Oswald</option>
</select>
<br>
<input type="color" name="tcolor" id="tcolor"
onchange="dynColor()" value="#000000">
<input type="color" name="bcolor" id="bcolor"
onchange="bColor()" value="#000000">
<script src="script.js"></script>
</body>
</html>

26
06/script.js

@ -0,0 +1,26 @@
function changeScolor() {
let colorList = document.getElementById("scolor");
let selectColorIndex = colorList.selectedIndex;
let futureColor =colorList.options[selectColorIndex].value;
document.getElementById("ltext").style.color = futureColor;
}
function changeSfont() {
let fontList = document.getElementById("sfont");
let selectfontIndex = fontList.selectedIndex;
let futurefont =fontList.options[selectfontIndex].value;
document.getElementById("ltext").style.fontFamily = futurefont;
}
function dynColor() {
let color = document.getElementById("tcolor").value;
console.log(color);
document.getElementById("ltext").style.color = color;
}
function bColor() {
let color = document.getElementById("bcolor").value;
console.log(color);
document.getElementById("ltext").style.backgroundColor = color;
}

0
06/style.css

Loading…
Cancel
Save