Appending a function to an existing onclick event at page load
Posted
by
tonsils
on Stack Overflow
See other posts from Stack Overflow
or by tonsils
Published on 2010-12-21T03:56:35Z
Indexed on
2010/12/21
5:22 UTC
Read the original article
Hit count: 228
jQuery
Hi,
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 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.
© Stack Overflow or respective owner