我试图将点击的事件(event.target)传递给单击时被调用的函数内的函数我将如何执行此操作?
function showGrid(){
updateTag()
}
function updateTag(){
/*how do i get the event.target passed here? */
alert(e.target)
}
$(".gridViewIcon").click(function(e) {
showGrid();
});
Run Code Online (Sandbox Code Playgroud)
只需通过函数调用传递event参数对象.
function showGrid(e){
updateTag(e);
}
function updateTag(e){
/*how do i get the event.target passed here? */
alert(e.target);
}
$(".gridViewIcon").click(function(e) {
showGrid(e);
});
Run Code Online (Sandbox Code Playgroud)
要将参数包含在嵌套的jQuery函数中,可以像这样在变量上创建一个闭包:
function updateTag(e){
alert(e.target);
...
var x = e;
something.each( function(i) { alert(x.target); } );
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4498 次 |
| 最近记录: |