Hide Div on out of focus using Javascript

Here is the Example of hiding Div on loosing focus
here i have mydiv which i want to hide on loosing focus so i used click event to check if it is having focus or not

<script language=”Javascript”>
document.onclick=check;
function check(e){
var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById(‘mydiv’);
if(target!=obj){obj.style.display=’none’}
}
</script>
</head>
<body>
<div id=”mydiv”>my div</div>
</body>
</html>

Advertisements

About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s