Hey guys I have a weird error
I wrote this code against setbubblepopup
$(document).ready(function () {
$(‘a’).hover(function () {
var tempID = $(this).attr("id");
var tempTitle = $(this).attr("title");
var totalID = ("'a#") + tempID + ("'");
console.log(totalID);
$(totalID).SetBubblePopup({
innerHtml: tempTitle
});
});
});
when I run it I get Selector expected.
The console log show me ‘a#thirdlink’ so I am getting the correct format
When I put:
$('a#thirdlink').SetBubblePopup({
innerHtml: tempTitle
});
it works with no errors that’s what is weird.
When I use my var totalID it doesn’t work and when I hard code it works.
You’re adding an extra set of quotes in there, this:
Should just be:
This isn’t a valid selector:
$("'a#something'"), but this is:$("a#something")🙂Overall though, an ID should be unique in the page, you can just use
$(this)instead of constructing a selector…if your IDs are unique,thisalready refers to the element you want, so this should work: