<script>
var e = document.getElementById("tab");
for(var i=0; e.rows && i<e.rows.length; i++){
for(var j=0; e.rows(i).cells && j<e.rows(i).cells.length; j++){
e.rows(i).cells.attachEvent("onclick",functionName);
/*
e.rows(i).cells.attachEvent("onclick",function(){
alert(this);
});
*/
}
}
function functionName(e){alert(e);}
</script><table id=tab></table>
没试~
var e = document.getElementById("tab");
for(var i=0; e.rows && i<e.rows.length; i++){
for(var j=0; e.rows(i).cells && j<e.rows(i).cells.length; j++){
e.rows(i).cells.attachEvent("onclick",functionName);
/*
e.rows(i).cells.attachEvent("onclick",function(){
alert(this);
});
*/
}
}
function functionName(e){alert(e);}
</script><table id=tab></table>
没试~
td
{
t:expression(this.onclick=function(){alert('clicked')});
background-color:red;width:100px;height:50px;
}
</style>
<script>
window.onload=function()
{
document.body.innerHTML+=('<table id=tb><tr><td>AAAAAA</td><td>BBBBB</td></tr></table>');
}
</script>