I have the following HTML code:
<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" />
Based on the above code, using jQuery, how can I replace all the above onclick calls to instead use my JavaScript function get_Count()
.
So the result I am after is:
<td align="center" class="shuttleControl">
<img src="/i/mydb/icons/shuttle_reload.png" onclick="get_Count();" alt="Reset" title="Reset"/>
<img src="/i/mydb/icons/shuttle_last.png" onclick=" get_Count();开发者_如何学运维" alt="Move All" title="Move All"/>
<img src="/i/mydb/icons/shuttle_right.png" onclick=" get_Count();" alt="Move" title="Move" />
<img src="/i/mydb/icons/shuttle_left.png" onclick=" get_Count();" alt="Remove" title="Remove" />
<img src="/i/mydb/icons/shuttle_first.png" onclick=" get_Count();" alt="Remove All" title="Remove All" />
</td>
I'd say something like:
$('img').unbind('click').click(get_Count);
EDIT:
Well, I tried that, and it doesn't work. What does work is .attr('onclick', '')
. So, do this:
$('.shuttleControl img').attr('onclick', '').click(get_Count);
If you're not needing those functions in g_Shuttlep_v61
at all, you could just overwrite them.
g_Shuttlep_v61.reset =
g_Shuttlep_v61.move_all =
g_Shuttlep_v61.move =
g_Shuttlep_v61.remove =
g_Shuttlep_v61.remove_all = get_Count;
Then there's no need to mess with the inline attributes.
精彩评论