lexeme lexeme - 1 year ago 99
Javascript Question

Operating with several items selected with JQuery

If selecting one item

is it possible to reference it inside event-handler using

  1. Howcome I reference items if I will use multiple items selection:

    $('#form1 td.item, #form2 td.item').event-handler(...{ })

  2. I need to fire an event when for example
    #form1 td.item
    #form2 td.item
    losts its focus. How do I do that?


So will
fire up on any of selector items:

$('#form1 td.item, #form2 td.item').blur(function() {
// something's there


Answer Source

If you attach an event handler to multiple items, each item will have the handler attached and will trigger it independently, so $(this) will refer to whichever item triggered the event