I’m having problems grabbing the title tag from an image in a slider and inserting it somewhere else on my page. It’s only grabbing the first title from the first image and not the subsequent ones.
My script:
var imgTitle = $('.nivoSlider img').attr('title')
$('a.nivo-control').append('<p>' + (imgTitle) + '</p>');
I know I have to use .each someplace but I don’t know where.
Thanks
Use
.map()to get an array of titles. Then use the index parameter in your call to.each()to get the corresponding title: