Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  33] [ 7]  / answers: 1 / hits: 15488  / 12 Years ago, wed, november 14, 2012, 12:00:00

I'm using this:



$('.sizeChart').on('vclick', '.entry .ui-btn', function(e){

console.log( e )
console.log( e.currentTarget )
console.log( $( e.currentTarget )
console.log( $( e.currentTarget ).find('input.qtyInput') )

var qty = $( e.currentTarget ).find('input.qtyInput');
// do something

});


Which works, but $( e.currentTarget ).find(...) seems awkward to me.



I can't bind directly to the input because this binding will go dead on iOS3+4 after a couple of clicks. Binding to the closest ui-btn works throughout.



Question:

Is there a better/easier/faster way to do the binding than what I'm using ?


More From » jquery

 Answers
53

You can just use this instead of e.currentTarget:



$(this).find(...);


Proof that event.currentTarget and this are the same.



Also the documentation says:




This property will typically be equal to the this of the function.







That's about it. It is pretty common to pass a DOM element directly to jQuery and use DOM traversal methods on it.


[#81996] Tuesday, November 13, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tina

Total Points: 91
Total Questions: 106
Total Answers: 104

Location: Vanuatu
Member since Fri, May 13, 2022
2 Years ago
;