jQuery: Triggering a click on an img not working
Posted
by Twecs
on Stack Overflow
See other posts from Stack Overflow
or by Twecs
Published on 2010-03-19T09:58:55Z
Indexed on
2010/03/19
10:01 UTC
Read the original article
Hit count: 157
I'm testing in Chrome.
I have a bunch of 'add item' icons on screen that the user can click in order to add that one item to the database. I also have a button at the botton of that list, which should add the whole list of items.
It seems to me that the easiest way to do this is to trigger the 'click' event for all these icons (the reason I'm doing it via the icons is that items-specific values are stored as attributes of the div in which the icon resides).
However, I can't get it to work: the event handlers for the individual icons work perfectly, and the event handler for the add-them-all button does give me an alert if I put that in. But if I add the
I read some posts that suggest browsers don't allow you to trigger click events, so I added a 'hover' event listener to the icons to see if the problem is in the type of event I want to trigger. Answer: no, same story: the alert will work, but the trigger won't.
I have placed the icon event listener in the code before the button event listener.
What's going on?
Twecs
© Stack Overflow or respective owner