Click here to Skip to main content
15,899,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As title. I am maintaining a web page system. I got a request that some tooltips are needed when cursor moves onto some element(dynamically created using JavaScript). I've
tried to use some ways to solve it, and it works well on very simple pages but no effect in my system. Could someone tells me what I am missing and how to solve it?
(Sorry for no jQuery because my system doesn't support this now.)

What I have tried:

AppendedElement = (AppendedElement != undefined) ? AppendedElement : document.getElementById(AppendedElementId);
        var Span = document.createElement("span");
        Span.style.display = "none";
        Span.style.position = "relative";
        Span.innerHTML = ToolTipText;
        AppendedElement.appendChild(Span);
        AppendedElement.addEventListener("mouseover", function () {
            Span.removeAttribute("style");
        });
        AppendedElement.addEventListener("mouseout", function () {
            Span.style.display = "none";
        });
Posted
Comments
ZurdoDev 18-Dec-18 9:12am    
You can set the title attribute and get the built-in tooltip.
PRAKASH9 19-Dec-18 2:16am    
Just write like below
AppendedElement.title = ToolTipText;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900