在页面加载时将函数附加到现有的onclick事件

时间:2010-12-21 03:56:36

标签: jquery

我有以下由我正在使用的应用程序编写的html代码,我无法访问,即

<td align="center" class="shuttleControl"> 
  <img src="/i/mydb/icons/shuttle_reload.png" onclick="g_Shuttlep_v61.reset();" alt="Reset"  title="Reset"/> 
  <img src="/i/mydb/icons/shuttle_last.png" onclick="g_Shuttlep_v61.move_all();" alt="Move All" title="Move All"/> 
  <img src="/i/mydb/icons/shuttle_right.png" onclick="g_Shuttlep_v61.move();" alt="Move" title="Move" /> 
  <img src="/i/mydb/icons/shuttle_left.png" onclick="g_Shuttlep_v61.remove();" alt="Remove" title="Remove" /> 
  <img src="/i/mydb/icons/shuttle_first.png" onclick="g_Shuttlep_v61.remove_all();" alt="Remove All" title="Remove All" /> 
</td> 

基于上面的代码,使用jQuery,当页面完成加载时,可能会搜索img src“shuttle_last.png”并附加到它的onclick调用,我自己的函数get_Count(); ?

也就是说,当我为这个特定行创建一个查看页面源时,我会看到以下代码,即:

<img src="/i/mydb/icons/shuttle_last.png" onclick="g_Shuttlep_v61.move_all();get_Count();" alt="Move All" title="Move All"/> 

这是否可行 - 如果是这样,会非常感谢代码示例吗?

感谢。

1 个答案:

答案 0 :(得分:1)

这不会起作用:

$('img[src$="shuttle_last.png"]').click(function() {
    get_Count();
});