var href = $(‘a[target=”_blank”]’).attr(‘href’);
$(‘a[target=”_blank”]’).attr(‘title’, ‘Öppnas i en ny flik; ‘ + href);
Let’s say I have a link in the header.php file with target="_blank". In the donate.php file I have another link with target="_blank". The code I show you above does only take the href value from the link in the header.php file. How do I take the href value in every link I have on the current page?
If I have the mouse cursor over the link in header.php, it will show “Öppnas i en ny flik; http://the-link.nu/“. If I have the mouse cursor over the link in donate.php, it will show “Öppnas i en ny flik; http://another-link.nu/“.
Any help to fix this problem? 🙂
Thanks in advance!
You’re only getting the first anchor’s attribute because $.attr() is designed to get just the value from the first matched element. Using $.each lets you loop through all of the elements found.