$('#myTable').click(function(e) {
var clicked = $(e.target);
clicked.css('background', 'red');
});
有人可以向我解释一下这一点,并解释为什么需要 e 以及它实际上做了什么。
Using e
只是一个缩写event
。您可以传递任何您想要的变量名称。
// would work just the same
$('#myTable').click(function(anyothername) {
var clicked = $(anyothername.target);
});
您可以查看更多jQuery 对事件的处理 http://jquery-howto.blogspot.com/2009/01/working-with-jquery-13-new-event-object.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)