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

问题描述 投票:0回答:1

我有以下由我正在使用的应用程序预先编写的 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"/> 

这可能吗?

jquery
1个回答
1
投票

这行不通:

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

© www.soinside.com 2019 - 2024. All rights reserved.