Forums

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

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #178024
    schart
    Participant

    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.

    #178036
    Senff
    Participant

    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.

    #178038
    Senff
    Participant

    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.

    #178128
    Senff
    Participant

    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.

    #178274
    Senff
    Participant

    @Soronbe — see one of my comments above about how the system flags comments. I unflagged it then, which is why it showed up again.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.