Iryna Bolbat 2 years ago
commit
c29047dac6
3 changed files with 72 additions and 0 deletions
  1. 16 0
      js_01/index.html
  2. 45 0
      js_01/main.js
  3. 11 0
      js_01/style.css

+ 16 - 0
js_01/index.html

@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="stylesheet" type="text/css" href="style.css">
+    <title>Document</title>
+</head>
+<body>
+    <input class="login" id="login" placeholder="login" type="email">
+    <input class="password" id="password" placeholder="password" type="password">
+    <button class="btn" id="btn">Login</button> 
+    <script src="main.js"></script>
+</body>
+</html>

+ 45 - 0
js_01/main.js

@@ -0,0 +1,45 @@
+//Первая часть ДЗ
+
+// let tomato = +prompt("Сколько помидор?");
+// let cucumber = +prompt("Сколько огурцов?");
+// let onion = +prompt("Сколько лука?");
+// let apple = +prompt("Сколько яблок?");
+// let orange = +prompt("Сколько апельсин?");
+// let kiwi = +prompt("Сколько киви?");
+
+// let vegitables = tomato + cucumber + onion;
+// alert(`Всего ${vegitables} овощей`);
+
+// let fruits = apple + orange + kiwi;
+// alert(`Всего ${fruits} фруктов`);
+
+// alert(`Всего ${vegitables + fruits} фруктов и овощей вместе`);
+
+
+//Вторая часть ДЗ
+
+var credentials = {
+    login: 'admin',
+    password: 'qwerty',
+};
+
+let log = document.getElementById('login');
+let pswd = document.getElementById('password');
+let btn = document.getElementById('btn');
+
+btn.onclick = function() {
+    let col;
+    let text;
+    if (log.value == credentials.login && pswd.value == credentials.password) {
+        col = 'green';
+        text = 'Congratulations';
+    } 
+    else {
+        col = 'red';
+        text = 'Error';
+    }
+    let div = document.createElement('div');
+    btn.insertAdjacentElement('afterend', div);
+    div.style.background = col;
+    div.innerText = text;
+}

+ 11 - 0
js_01/style.css

@@ -0,0 +1,11 @@
+input {
+    width: 200px;
+    height: 30px;
+}
+
+.btn {
+    width: 100px;
+    height: 30px;
+    background-color: aquamarine;
+    border:1 solid rgb(57, 63, 63);
+}