I'm having an issue with jQuery where when selecting an element with nth-of-type()
within the bound function, it will not allow me to access it with $(this)
$(".panel:nth-of-type(2)").on('click', (e) => {
alert("CLICKED PANEL 2");
$(this).css({
background: "red"
});
});
The above will run the alert()
but the $(this)
does not get hit and throws no errors. If I change the $(this)
to $(".panel:nth-of-type(2)")
it will then work without any issues.