-1
<div id="divTest1">hi</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<script type="text/javascript">
function DocumentReady(event)
{
       console.log(event.type); 
}

$('#divTest1').click(DocumentReady(event));
</script>

问题:

在 chrome->console 中,它显示:Uncaught TypeError: Cannot read property 'type' of undefined,那么上面的代码出了什么问题?

4

1 回答 1

1

您正在调用DocumentReady并将其结果作为$('#divTest1').click.

只需传递函数:

$('#divTest1').click(DocumentReady);
于 2013-07-08T01:43:30.510 回答