I have a link, and I want to display a description in a tooltip when hovering. I've been using setAttribute, but it does not work:
let link = document.createElement("a");
link.setAttribute("href", `http://mylink.co/${element.key}`);
link.setAttribute("target", "_blank");
link.setAttribute("onmouseover", element.description); // <----- here
link.innerHTML = element.key + ": " + element.summary;
I know this shouldn't be this complex but I'm not very familiarized with JavaScript.
I also tried adding it as function:
link.onmouseover = function() { element.description) }
that you need is to add this: