- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Cant handle events on dynamically created element
I tried looking at this with no success btw: http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements
Here’s a version mirroring my problem in CodePen: http://codepen.io/anon/pen/uzayI
I tried “$().on()” instead of “$().hover()” but it doesn’t really help.
I don’t think this is really valid:
$(".jumper").on("mouseover mouseout", "select", function(e){
When you change it to this, it works fine:
$(".jumper").on("mouseover mouseout", function(e){
Not sure what you intended to do with the “select”, but it can’t be there.
P.S. @soronbe : your comment was flagged by the system. Probably because it contained JavaScript, and we’re having a few troubles with showing/formatting code in posts lately…it’s a little funky sometimes.
From the original pen, I understood that the link (with class “jumper”) is created on body load (by the “tweetify” function).
Then when you hover over that “jumper” link (mouseon or mouseover), the word “hovered” is added.
So from that example, I didn’t think that the jumper link had to be created on a mouseover — I thought that the mouseover had to happen on the jumper.