Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Add Tooltip

  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add Tooltip

    Hello Sir,

    I am developing a HTML page in which I have generated a Dynamic Div means after clicking on a button a div will be generated With Different Id,
    Now my problem is that I want to add ToolTip to that dynamically generated Div, But the Text of Tooltip not the Stable which is also dynamic means Suppose i generate 3 Divs with id = 1, id = 2, and id = 3,then when I Hover the mouse on each div then the tooltip text will be 1,2 and 3 respectively.

    my code is..

    for(i=0;i<10;i++){
    mainDiv = document.getElementById("txtHint");
    dynDiv = document.createElement("div");
    dynDiv.id = i
    mainDiv.appendChild(dynDiv);
    dynDiv.className = 'myDiv';
    dynDiv.onmouseover=function(){Tip(dynDiv.id);}
    dynDiv.onmouseout=function(){UnTip();}
    }
    I have search om web but enable to solve this problem, Please Help Me...
    Thanks
    Last edited by nirus123; 07-28-2009 at 07:20 AM. Reason: Add Code

  • #2
    New Coder
    Join Date
    Jun 2009
    Posts
    35
    Thanks
    0
    Thanked 2 Times in 2 Posts
    U may set attribute title to show the tooltip for each div tag separately. Follow the below code.
    Code:
    for(i=0;i<10;i++){
    mainDiv = document.getElementById("txtHint");
    dynDiv = document.createElement("div");
    dynDiv.id = i
    dynDiv.innerHTML = "Div Tag "+i;
    
    dynDiv.setAttribute('title','tool tip'+i);
    mainDiv.appendChild(dynDiv);
    }
    Live chat software - chat with your web site visitors in real time.
    Internet web directory - list of top100 sites in diffrent category


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •