Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts

    bind() vs fixed event names?

    My usual way of attaching event handlers is:

    Code:
    $('#element').click(function(){...});
    I'm seeing this method, however, and I was just wondering what the significant differences were and if I should be using one or t'other...

    Code:
    $('#element').bind('click', function(){...});

  2. #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    The bind allows you to add a single callback to multiple events e.g.
    Code:
    $('#element').bind('click mouseover', function(){
    });
    It also allows you to pass data to the event handler.

    View http://docs.jquery.com/Events/bind for more information.

  3. Users who have thanked Iszak for this post:

    Spudhead (05-05-2009)


 

Posting Permissions

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