Сообщение от Doktor1962
|
//нужна восстновить функцию 'bukva(this)' color(this) и значения ячеек
|
Какие проблемы то?
<!doctype html>
<html lang="uk">
<head>
<script>
function otmena(obj)
{
//нужна восстновить функцию 'bukva(this)' color(this) и значения ячеек
const cells = document.querySelectorAll('td');
cells[0].innerText = 'А';
cells[1].innerText = 'В';
cells[2].innerText = 'Ж';
cells[3].innerText = 'З';
cells[0].onclick = cells[1].onclick = function () {bukva(this)};
cells[2].onclick = cells[3].onclick = function () {color(this)};
cells[2].style.backgroundColor = cells[3].style.backgroundColor = 'white';
}
function bukva(obj)
{
alert(obj.innerText);
}
function color(obj)
{
obj.style.background="yellow";
obj.onclick=function(e){
obj.style.background="green";
obj.onclick=null;
}
}
function slovo()
{
alert(this.id);
}
function nove()
{
var mmm=document.getElementsByTagName('td');
for(i=0;i<4;i++)
{
mmm[i].innerText="Y"+i;
mmm[i].onclick=slovo;
}
}
</script>
<meta charset="utf-8">
<title>пример</title>
</head>
<body>
<input type='button' id='jk' value='Вперед' onclick='nove()'/>
<input type='button' id='otm' value='Назад' onclick='otmena()'/>
<p id= "Буквы"></p>
<table width='200px' height='200px' border="1">
<tr><td id="1" onclick= 'bukva(this)'>А</td><td id="2" onclick= 'bukva(this)'>В</td></tr>
<tr><td id="3" onclick= 'color(this)'>Ж</td><td id="4" onclick= 'color(this)'>З</td></tr>
</table>
</body>
</html>