Codex
Codex

Reputation: 78

How to show div on textbox control using javascript?

I am stucked into an issue,as i have captured the mouseover event on textbox.Here is code of mouseOvering;

<script type="text/javascript">

window.onload=function(){
document.getElementById("dijit_form_Textarea_0").attachEvent("onmouseover",function(){
document.getElementById("div_1_1_1").style.display = 'block';
document.getElementById("dijit_form_Textarea_0").setAttribute("title",'Hello World');

});

This code works fine and shows tooltip when mouse is over on particular textbox. Now i want to show div on mouseOvering instead of showing tooltip.

How can i accomplish this task,can anyone assist me?

Upvotes: 1

Views: 70

Answers (3)

Banana
Banana

Reputation: 7463

create a div with the tip you want, set its position to 'absolute' and set its left/top to the place u want it to appear

see an example Here

Upvotes: 1

Suman Bogati
Suman Bogati

Reputation: 6349

The attachEvent() is used for IE browsers, use addEventListener() to other browsers(FF and Chrome).

document.getElementById("dijit_form_Textarea_0").addEventListener("mouseover",

For IE and Other browsers you could do like this.

window.onload=function(){
    var div = document.getElementById("dijit_form_Textarea_0");
    if (div.addEventListener) {
        div.addEventListener('mouseover', changeStyle);
    } else if (div.attachEvent) {
        div.attachEvent("onmouseover", changeStyle);
    }

    function changeStyle(){
        document.getElementById("div_1_1_1").style.display = 'block';
        document.getElementById("dijit_form_Textarea_0").setAttribute("title",'Hello World');
    }
);

Upvotes: 0

BlackPearl
BlackPearl

Reputation: 2775

Let say your div have id="mydiv"

<div I'd="mydiv"></div>

In the place where you entered the code for showing the title, put the following

$('#mydiv').show(); 

 And you want to hide the div, use

$("#mydiv").hide();

Upvotes: 0

Related Questions