I'm trying to get the href
value of an anchor tag using jQuery, but the this
keyword is not working as expected.
Here is the result of the code in the console:
The part of the code I have problem with:
$('#container a').click(() => {
console.log(this);
let link = $(this).attr("href");
console.log("from jquery - " + link);
//chrome.tabs.create({ url: link });
});
As you can see, the this
keyword is pointing on the window
object.
This code is part of an extension I'm trying to build for Opera.