Vadym Hlushko 2 năm trước cách đây
mục cha
commit
ad4bcf29ff
2 tập tin đã thay đổi với 43 bổ sung0 xóa
  1. 3 0
      hw9/.vscode/settings.json
  2. 40 0
      hw9/main.js

+ 3 - 0
hw9/.vscode/settings.json

@@ -0,0 +1,3 @@
+{
+    "liveServer.settings.port": 5501
+}

+ 40 - 0
hw9/main.js

@@ -37,3 +37,43 @@ fetch('https://raw.githubusercontent.com/russ666/all-countries-and-cities-json/m
 
 //tableMouseTask
 
+let table = document.createElement('table');
+document.body.appendChild(table)
+table.style.marginTop = '100px'
+
+for (let i = 0; i <= 9; i++){
+		let tr = document.createElement('tr');
+	
+	  for (let j = 0; j <= 9; j++){
+		let td = document.createElement('td');
+		td.style.padding = "5px";
+		td.style.border = "2px solid black";
+		if(i === 0) td.innerText = j;
+		else if(j === 0) td.innerText = i; 
+		else td.innerHTML = i*j;
+        tr.appendChild(td);
+
+        td.onmouseover = function (event) {
+            for (let i = 0; i < table.children.length; i++) {    
+                table.children[i].children[j].style.background = "lightgreen";
+            }
+            tr.style.background = "lightgreen"  
+            td.style.background = "lightgreen"
+            td.style.boxShadow = "0px 5px 10px 2px rgba(34, 60, 80, 1)" 
+            tr.style.boxShadow = "0px 5px 10px 2px rgba(34, 60, 80, 1)"
+        }
+
+        td.onmouseout = function (event) {
+            for (let i = 0; i < table.children.length; i++) {
+                table.children[i].children[j].style.background = "";
+            }
+            tr.style.background = ""
+            td.style.background = ""
+            td.style.boxShadow = ""
+            tr.style.boxShadow = ""
+        }
+    }
+    table.appendChild(tr);
+}
+document.body.appendChild(table);
+