Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery: keypress event should only function once

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #45533
    Kajrietberg
    Member

    Hi,

    I’m using a keypress event on a input type=text. When someone is starting to type the keypress is started and will put a textarea into the document. But it should only do this ones. Now it does it with every key that is pressed. So I get as many textarea’s with every letter I’m typing of my sentence.

    #138712
    Paulie_D
    Member

    We’d need to see a link but it sound to me as though your jQuery is not specific enough in it’s targeting.

    #138747
    Kajrietberg
    Member

    If you go to: http://popaquestion.com/kaj/ and start typing, then you will see.

    #138753
    CrocoDillon
    Participant

    Not sure what you are trying to do… but you could remove the event listener in the event callback, but everything inside http://popaquestion.com/kaj/js/animatie.js will only fire once then.

    #138904
    pixelgrid
    Participant

    $(‘input’).bind(‘keyup’,function(event){
    //Show second input
    $(this).unbind(event);
    });

    #138971
    Kajrietberg
    Member

    Thanks guys, will try these methods today!

    #138989
    Kajrietberg
    Member

    I used the solution of @Hompimpa. It works. Thanks. I’m just starting with learning jQuery.

    #191155
    Hasan Junaid Hashmi
    Participant

    I used following
    if($($(this)).val().length ==1),Because I am lazy

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