I have problems understanding how $this works in .closest().
$(".link").click(function () {
$(this).closest("li").find(".class").removeClass('my-class');
});
I understand, that in this case, this refers to the .link class which is clicked. This is what works.
Now if I want to create a function which I would call on click, it will not work obviously:
const myFunction = () => {
$(this).closest("div").find(".class").removeClass('my-class');
}
$(".link").click(myFunction);