Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "this" stand for here?

Given the code:

$(element, document).mousedown(function() {
        $(this).attr('id'); // get id of the element

});

how to rewrite the code without using this?

like image 339
sam.smith Avatar asked Apr 01 '26 13:04

sam.smith


1 Answers

what is THIS stands for?

In this context, this points to the element that you are currently defining the mousedown property for.

I can't see a reason not to use it here. Can you elaborate on what you want to do?

like image 142
Pekka Avatar answered Apr 04 '26 02:04

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!