CrazyWeed0907 发表于 2007-11-16 13:11

[求助] javascript创建元素添加事件问题

&lt;script type="text/javascript"&gt;<BR><BR>  function  text()<BR>{<BR>    alert();<BR>}<BR><BR>function createItem()<BR>{<BR>    table = document.createElement("Table")<BR>   <FONT color=#ff0000> table.onclick = function(){text();}</FONT><BR>    body.appendChild(table)<BR>}<BR><BR>&lt;/script&gt;<BR><BR>这里的红色部分为什么不行啊,帮我看看<BR><BR>

zhulei1978 发表于 2007-11-25 15:28

<script type="text/javascript">

function text()
{
alert();
}

function createItem()
{
table = document.createElement("Table")
[color=black]table.onclick = function(){text();}[/color]
[color=red]document.[/color]body.appendChild(table)
}

</script>

渚薰 发表于 2007-11-26 08:49

function text()
{
alert("1");
}

页: [1]

编程论坛