main.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //multiply table если поменять обявление колонок то можно будит подсвечивать сразу все ячейки колонки
  2. /* let boddy = document.querySelector('body');
  3. let table = document.createElement('table')
  4. let tbody = document.createElement('tbody')
  5. for(let rowIndex = 1; rowIndex<10; rowIndex++){
  6. let rows = document.createElement('tr');
  7. for(let cellIndex = 1; cellIndex<10; cellIndex++){
  8. let cell = document.createElement('td');
  9. let cellText = document.createTextNode(rowIndex*cellIndex);
  10. cell.appendChild(cellText);
  11. rows.appendChild(cell);
  12. cell.onmouseover = function(event) {
  13. event.target.style.background = "silver";
  14. }
  15. cell.onmouseleave = function(event) {
  16. event.target.style.background = "";
  17. }
  18. }
  19. tbody.appendChild(rows);
  20. rows.addEventListener("mouseover", function hoverOnRow(){
  21. this.style.backgroundColor="green";
  22. });
  23. rows.addEventListener("mouseleave", function hoverOnRowEnd(){
  24. this.style.backgroundColor="";
  25. });
  26. }
  27. table.appendChild(tbody);
  28. boddy.appendChild(table);
  29. */
  30. /* let sumBtn = document.getElementById('calc'); */
  31. /* function sumNumbers(a,b) {
  32. return a+b;
  33. } */
  34. /* sumBtn.addEventListener('click', function sumNumbers(){
  35. let firstNumber = +(document.getElementById('firstNumber').value);
  36. let secondNumber = +(document.getElementById('secondNumber').value);
  37. return console.log(firstNumber+secondNumber);
  38. }) */
  39. /* document.getElementById('firstNumber').addEventListener('change',calc,false);
  40. document.getElementById('secondNumber').addEventListener('change',calc,false);
  41. function calc() {
  42. let firstNumber = +(document.getElementById('firstNumber').value);
  43. let secondNumber = +(document.getElementById('secondNumber').value);
  44. document.getElementById('result').value = firstNumber + secondNumber;
  45. }
  46. calc(); */
  47. let input1 = document.getElementById('firstNumber');
  48. let input2 = document.getElementById('secondNumber');
  49. function calc() {
  50. let result = document.getElementById('result');
  51. result.value = (+input1.value) + (+input2.value)
  52. }
  53. input1.oninput = calc;
  54. input2.oninput = calc;
  55. /* sumNumbers(firstNumber,secondNumber); */