Сообщение от bes
|
<style>
td {border: solid 1px; cursor: pointer}
</style>
<table id="myTable">
<tr>
<td id="1">first
<td id="2">second
<td id="3">third
<tr>
</table>
<script>
myTable.onclick = function (e) {
var e = e || window.event;
var target = e.target || e.srcElement;
target.innerHTML = target.id
}
</script>
|
Id
не нужен.
<style>
td {border: solid 1px; cursor: pointer}
</style>
<table id="myTable">
<tr>
<td>first
<td>second
<td>third
<tr>
</table>
<script>
myTable.onclick = function (e) {
var target = e ? e.target : window.event.srcElement;
target.innerHTML = target.cellIndex
}
</script>