Appending a function to an existing onclick event at page load
I have the following html code that is pre written by the app I am using, which I do not have access to, i.e.
<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>
Based on the above code, using jQuery, would it be possible that when 开发者_StackOverflow社区the page finishes loading, search for the img src "shuttle_last.png" and append to it's onclick call, my own function get_Count(); ?
That is, I would then see the following code when I do a view page source for this particular line, i.e.:
<img src="/i/mydb/icons/shuttle_last.png" onclick="g_Shuttlep_v61.move_all();get_Count();" alt="Move All" title="Move All"/>
Is this possible - if so, would really appreciate a code sample?
Thanks.
Will not this work:
$('img[src$="shuttle_last.png"]').click(function() {
get_Count();
});
?
精彩评论