Advertisements
What i tried :
const adressLine = $('.adressLine');
adressLine.on('click',()=>{
console.log('button cliked');
var text = adressLine.text();
console.log(text);
});
console result, i get all of the strings, not what i want :
so i find a solution in other discussions:
const adressLine = $('.adressLine');
adressLine.on('click',()=>{
console.log('button cliked');
var text = $(this).text();
console.log(text);
});
it returned me an empty string , why ?
>Solution :
This happens because you are using an arrow function.
Try with
const adressLine = $('.adressLine');
adressLine.on('click',function(){
console.log('button cliked');
var text = $(this).text();
console.log(text);
});