Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>zadaca3</title>
- <style>
- #gore {
- margin-left: 80px;
- padding-bottom: 10px;
- }
- button {
- margin-top: 10px;
- margin-left: 133px;
- }
- #containter{
- display: inline-block;
- margin-left: 35%;
- margin-top: 25%;
- }
- </style>
- </head>
- <body>
- <div id="containter">
- <div id="gore">
- <input type="radio" value="color" name="selektor" checked>Color
- <input type="radio" value="image" name="selektor">Image<br>
- </div>
- <div>
- <label>Value: </label><input type="text" id="vid"><br>
- <button onclick="promeni();">Промени</button>
- </div>
- </div>
- </body>
- </html>
- <script>
- function promeni() {
- document.body.style.backgroundImage = "";
- var radios = document.getElementsByName('selektor');
- var input = document.getElementById('vid').value;
- if (radios[0].checked == true) {
- document.body.style.backgroundColor = input;
- }
- else if (radios[1].checked == true) {
- document.body.style.backgroundImage = "url('"+input+"')";
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement