Investigating a bit of jquery, I found this function:
$(document).on('click', '.class', function () {
let element = $(this)[0]
let search = $(element).attr('dat')
console.log(element)
})
I am learning javascript - I still do not know much, I realized that with this function I save the selected element, I would like to know how the function from above could pass to javascript, and also if possible explain to me what is doing the this
and the [0]
, I've seen the this
very often, but I find it hard to understand.