Match event.target with existing jQuery object

前端 未结 4 2036
走了就别回头了
走了就别回头了 2020-12-31 14:38

How can I do that?

event.target returns a HTML object,

and my element is a jQuery object.

Is there a better way to find out if event.tar

4条回答
  •  借酒劲吻你
    2020-12-31 15:05

    Actually, I found another way, much more handy one :) Just need to use the data argument:

    Data to be passed to the handler in event.data when an event is triggered.

    Now my code looks like this:

    var inp = $('');
    inp.focus( { j : inp } , $.proxy( this.onInpFocus, this ) );
    
    //and the handler method
    onInpFocus : function( e )
    {
    var inp = e.data.j;
    ...
    }
    

提交回复
热议问题