<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<style>
.osnova-test{
width : 50px;
height:50px;
font-size: 16px;
}
</style>
<input type="button" value=" " class="osnova-test" id="b1" onclick="myfunc(1)">
<input type="button" value=" " class="osnova-test" id="b2" onclick="myfunc(2)">
<input type="button" value=" " class="osnova-test" id="b3" onclick="myfunc(3)">
<br>
<input type="button" value=" " class="osnova-test" id="b4" onclick="myfunc(4)">
<input type="button" value=" " class="osnova-test" id="b5" onclick="myfunc(5)">
<input type="button" value=" " class="osnova-test" id="b6" onclick="myfunc(6)">
<br>
<input type="button" value=" " class="osnova-test" id="b7" onclick="myfunc(7)">
<input type="button" value=" " class="osnova-test" id="b8" onclick="myfunc(8)">
<input type="button" value=" " class="osnova-test" id="b9" onclick="myfunc(9)">
<script>
function myfunc(n){
let nodeList = document.querySelectorAll(".osnova-test");
for (let i = 0; i < nodeList.length; i++) {
if (i == n-1){
nodeList[i].value = i+1;
}
}
}
</script>
</body>
</html>
|