I have a function like:
$(".myDropdown").hover(function() {
  $(this).find(".myDropdown-caretDown").hide();
}, function() {
  $(this).find(".myDropdown-caretDown").show();
});
If I want to use lambda function for hover callback, What can I use instead of this?
this inside arrow function is the same object as this in the scope that defines this function:
$(".myDropdown").hover(
  e => $(e.target).find(".myDropdown-caretDown").hide(),
  ...
});
                        What can I use instead of this?
Use event.target
$(".myDropdown").hover('click', (event) => {
    $(event.currentTarget).find(".myDropdown-caretDown").hide();
  },(event) => {
    $(event.currentTarget).find(".myDropdown-caretDown").show();
  },);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With