Reputation: 56
Why it can't work when i use
$('.pc-nav>li').map((x)=>$(x).text())
to get innerText while
$('.pc-nav>li').map(function(){return $(this).text()})
is ok?
Upvotes: 1
Views: 105
Reputation: 138267
Cause x
is not the element, but its position (index) in the collection. Take the second argument (the actual element which you want):
$('.pc-nav>li').map((pos, el) => $(el).text())
And next time, check the docs first...
Upvotes: 1