I have a list of links with a title and a href value. I would like to be able to get these values seperately, but I always get the first link's values. Why is that? See my fiddle here. As you can see - when clicking a any of the link, you always get the values from the first link. I guess setting these variables isn't sufficient:
var title = $('.mg_phones').attr('title');
var url = $('.mg_phones').attr('href');
Any ideas?
You have to refer to the clicked element:
var title = $(this).attr('title');
var url = $(this).attr('href');
You need to change the code to this:
var title = $(this).attr('title').toLowerCase();
var url = $(this).attr('href');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With