SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast justinpalmer's Avatar
    Join Date
    Oct 2005
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Jquery Click or Press and Hold

    Hi,

    I have a task of building a button that a user can click or press and hold.

    Basically it would act like a telegraph machine.

    If the user presses and holds it should fire an event.

    If the user clicks on the button it should fire another event.

    Any ideas where to start?

    Many thanks,

    Justin
    Justin Palmer
    MySQL v.5

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    jQuery bind() is what your seeking, you can set multiple events to it and then have the event do something

    http://api.jquery.com/bind/

    For what your wanting you would use

    Code JavaScript:
    $(document).ready(function(){
        $('#id-here').bind('click mousedown', function(){
            // Do something here
        });
    });


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •