Hi guys, I've a problem using setAttribut and event. Let me explain in detail: I have to create a table with js, and set an onClick event on every cell, so that a function with argument "this" is executed every time the user click on a table cell.
To do so, I've coded something like:
In the example, I've created a table with only one cell, but in reality I need a far complex table. The fact is, even with this simple source, i get what i want in firefox, but with IE i can't get the onclick event executed ...
Can someone tell me where's the "mistake"?
To do so, I've coded something like:
Code:
<html>
<body>
<script>
function insert_table(){
var t = document.createElement("table");
var tb = document.createElement("tbody");
var tr = document.createElement("tr");
var td = document.createElement("td");
td.setAttribute('onClick','aa(this)');
td.innerHTML = 'a';
tr.appendChild(td);
tb.appendChild(tr);
t.appendChild(tb);
document.body.appendChild(t);
}
function aa(t){
alert(t.innerHTML);
}
insert_table();
</script>
</body>
</html>
Can someone tell me where's the "mistake"?