Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi..
i am trying to Hide a DIV when it loses focus/blur using JavaScript.But gives reverse effect.i am calling function on onmouseover and also onmousemove events of div, set diaplay property to none.but on mouseover it hide.i want to hide a div on focus loss using javascript provide solution.My code is
HTML
divLst.Attributes.Add("onmousemove", "HideShowDiv('none');")

or
HTML
divLst.Attributes.Add("onmouseout", "HideShowDiv('none');")

javascript function:
JavaScript
function HideShowDiv(val) {
    var myDiv = document.getElementById('GridControl1_divLst');
    myDiv.style.display = val;
}


thanx
Posted
Updated 3-Sep-12 19:50pm
v2
Comments
Sergey Alexandrovich Kryukov 4-Sep-12 1:55am    
If you want to do it on focus loss, why do you try to handle totally unrelated on mouse move/out?
--SA
Sandeep Mewara 4-Sep-12 2:00am    
Yep. Shared the same thought in my answer. Based on the need, one can implement the behaviour.

1 solution

onmousemove is a wrong event you are using for your need.

Use (choose event based on your need):
onmouseover OR onfocus: for showing the div
onmouseout OR onblur: for hiding the div

Further, to hide, use: display = none;
to show, use: display = block;
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 4-Sep-12 14:50pm    
I voted 4. I would also explain that div is not a focusable element; OP needs to use some control to add a handler to it, but show/hide some other element, such as div. Also, I don't see what event should show the element again -- it's important to understand that a hidden element cannot invoke any events.
--SA

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