Всем добрый день.
Не могу понять почему не срабатывает выполнение действия по Id
<p>
<table>
<tr><td id="question_text"></td></tr>
<tr>
<td id="answer_1"></td>
<td id="answer_2"></td>
</tr>
<tr>
<td id="answer_3"></td>
<td id="answer_4" ></td>
</tr>
</table>
</p>
<input type="button" id="" onclick="CreateIdInput();id_selecter()" value="">
<script>
function CreateIdInput()
{
for(var i =1; i < 5; i++)
{
var td = document.getElementById("answer_" +i);
var new_id ="<input type='button' id ='t"+i+"' onclick='test_click()' value='t_"+i+"'>";
td.innerHTML = new_id;
}
}
</script>
<script>
function id_selecter()
{
var rand_select_computer = Math.floor(Math.random()*3);
var arr_select_computer = [0, 1, 2, 3];
var select_computer = arr_select_computer[rand_select_computer];
if ( select_computer == 0)
{
alert("1")
document.getElementById('t_1').style.display = "none";
}
else if (select_computer == 1)
{
alert("2")
document.getElementById('t_2').style.display = "none";
}
else if (select_computer == 2)
{
alert("3")
document.getElementById('t_3').style.display = "none";
}
else if (select_computer == 3)
{
alert("4")
document.getElementById('t_4').style.display = "none";
}
}
function test_click()
{
alert("work")
}
</script>