[jQuery] Problem with Selecting Multiple Elements
I've run into an issue with JQuery that I'm not quite sure how to work
around. Hopefully someone can help. Basically, I'm trying to go
through a page and apply a tooltip to all the links with a certain
class.
I am able to select the attributes just fine, and apply the tooltip
plugin to each of them, using code like this:
$("a[@id^=note]").tooltip();
The issue here is that I would like to set some options in the
tooltip, so that the tooltip displays text from the target of the
link. I need to somehow be able to access the href of the link that
I'm applying the tooltip to.
I tried this code:
$("a[@id^=note]").tooltip({
bodyHandler: fetchLink($(this).attr("href"))
});
which does not work.
I also tried pulling all the links into an array, which I would then
iterate through grabbing the href and then applying the tooltip, but I
am getting "undefined" for all the hrefs when I try this:
var noteLinks = $("a[@id^=note]");
for(var i in noteLinks) {
var url = $(i).attr("href");
}
Ideally, I can do this with chaining somehow, as in the first
example. If not, then why is my second method not working either??
Seems like the second method should work for sure...