jquery / javascript:function(e){....什么是e?为什么需要?它实际上做什么/完成了什么? [英] jquery/javascript: function(e){.... what is e? why is it needed? what does it actually do/accomplish?
本文介绍了jquery / javascript:function(e){....什么是e?为什么需要?它实际上做什么/完成了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var clicked = $(e.target);
clicked.css(' background','red');
});有人可以向我解释一下,并解释为什么需要e,以及它实际上是什么..
解决方案
使用 e
只是事件
。你可以传递你想要的任何变量名。
//将工作只是一样的
$('#myTable' ).click(function(anyothername){
var clicked = $(anyothername.target);
});
您可以在 jQuery处理事件。
$('#myTable').click(function(e) {
var clicked = $(e.target);
clicked.css('background', 'red');
});
Can someone explain this to me, and explain why e is needed, and what it actually does..
解决方案
Using e
is just a short for event
. You can pass any variable name you desire.
// would work just the same
$('#myTable').click(function(anyothername) {
var clicked = $(anyothername.target);
});
You can check out more on jQuery's handling of events.
这篇关于jquery / javascript:function(e){....什么是e?为什么需要?它实际上做什么/完成了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文