I have an AHAH-requested HTML, like:
<table>
<tr>
<td>...</td>
<td><img src="..." onClick="get_next_ahah(sell####)" id="sell####"/></td>
</tr>
<tr>
<td>...</td>
<td><img src="..." onClick="get_next_ahah(sell####)" id="sell####"/></td>
</tr>
... and so on
where #### – numerical IDs from DB.
How can I replace the function “get_next_ahah()” on efficient event-written jQuery function? And how can I find out which id I use?
You can use a rather obscure form of CSS selector to grab all elements whose ID contains the text “sell” and then use that to assign events to them:
Or, if the elements are all guaranteed to be
imgs, you can use this more specific selector instead:These selectors will both return an array of elements that have “sell” in the ID, which you can call
click()on.To find out the current ID, you can just strip “sell” from the ID and then pass that to your
get_next_ahah()function, like this: