// Таблица умножения =========================================================================== const table = document.createElement('table') document.body.append(table) Object.assign(table.style, {width: '435px', height: '385px'}) for (let i=0; i<10; i++){ const tr = document.createElement('tr') table.appendChild(tr) for(let j=0; j<10; j++){ const td = document.createElement('td') Object.assign(td.style, {border: '1px solid', borderColor: '#e1e1e3', textAlign: 'center', width: '20px'}) tr.appendChild(td) let mTable = i*j mTable= mTable? mTable: j||i i%2? td.style.backgroundColor='#f8f8f8': td.style.backgroundColor='#ffffff' td.innerText=mTable } } // Подсветить ячейку =========================================================================== const table = document.createElement('table') document.body.append(table) Object.assign(table.style, {width: '435px', height: '385px'}) for (let i=0; i<10; i++){ const tr = document.createElement('tr') table.appendChild(tr) for(let j=0; j<10; j++){ const td = document.createElement('td') Object.assign(td.style, {border: '1px solid', borderColor: '#e1e1e3', textAlign: 'center', width: '20px'}) tr.appendChild(td) let mTable = i*j mTable? mTable===0: mTable = j||i i%2? td.style.backgroundColor='#f8f8f8': td.style.backgroundColor='#ffffff' td.innerText=mTable td.onmouseover = function(){ this.style.backgroundColor='#ffba00' } td.onmouseout = function(){ i%2? td.style.backgroundColor='#f8f8f8': td.style.backgroundColor='#ffffff' } } } // Подсветить строку и столбец =========================================================================== const table = document.createElement('table') document.body.append(table) Object.assign(table.style, {width: '435px', height: '385px'}) for (let i=0; i<10; i++){ const tr = document.createElement('tr') table.appendChild(tr) for(let j=0; j<10; j++){ const td = document.createElement('td') Object.assign(td.style, {border: '1px solid', borderColor: '#e1e1e3', textAlign: 'center', width: '20px'}) tr.appendChild(td) let mTable = i*j mTable? mTable===0: mTable = j||i i%2? td.style.backgroundColor='#e9e9e9': td.style.backgroundColor='#ffffff' td.innerText=mTable td.onmouseover = function(){ td.style.backgroundColor='#d0bf55' tr.firstChild.style.backgroundColor='#6768ab' table.firstChild.children[j].style.backgroundColor='#6768ab' } td.onmouseout = function(){ i%2? td.style.backgroundColor='#e9e9e9': td.style.backgroundColor='#ffffff' i%2? tr.firstChild.style.backgroundColor='#e9e9e9': tr.firstChild.style.backgroundColor='#ffffff' table.firstChild.children[j].style.backgroundColor='#ffffff' } } } // Либо ================================= const table = document.createElement('table') document.body.append(table) Object.assign(table.style, {width: '435px', height: '385px'}) for (let i=0; i<10; i++){ const tr = document.createElement('tr') table.appendChild(tr) for(let j=0; j<10; j++){ const td = document.createElement('td') Object.assign(td.style, {border: '1px solid', borderColor: '#e1e1e3', textAlign: 'center', width: '20px'}) tr.appendChild(td) let mTable = i*j mTable = mTable? mTable: j||i i%2? td.style.backgroundColor='#e9e9e9': td.style.backgroundColor='#ffffff' td.innerText=mTable td.onmouseover = function(){ td.style.backgroundColor='#d0bf55' for(let k=0; k<10; k++){ td.parentElement.children[k].style.backgroundColor='#6768ab' td.style.backgroundColor='#d0bf55' } for(let l=0; l