Tapan
1
Hello,
I have simple code which shows a div and then on click it hides the div but its not working:
hidediv(divID)
{
var box = document.getElementById(divID);
box.style.display = "none";
}
$(document).ready(function()
{
$("#notification").hide();
$("#notification").load("#notification");
$("#notification").slideDown("slow");
});
<div id="notification"><a href="somelink.htm" onclick="javascript:hidediv('notification'); return false;" target="_blank"><img src="./images/chat_popup.png" border="0" /></a></div>
How to fix this ?
Thanks.
rpkamp
2
Your “hidediv” is not defined as function, you should do it like:
function hidediv(divID)
{
var box = document.getElementById(divID);
box.style.display = "none";
}
$(document).ready(function()
{
$("#notification").hide();
$("#notification").load("#notification");
$("#notification").slideDown("slow");
});
But, seeing as you use jQuery, why don’t you do it like so:
<div id="notification"><a href="somelink.htm" id="notificationlink" target="_blank"><img src="./images/chat_popup.png" border="0" /></a></div>
$(document).ready(function()
{
$("#notification").hide();
$("#notification").load("#notification");
$("#notification").slideDown("slow");
$("#notificationlink").click( function() { $("notification").hide(); return false; } );
});
Tapan
3
Hello,
Thanks for the help. How to hide the div after 10 seconds ?
Thanks.
rpkamp
4
Take a look at javascripts setTimeout() function.
Tapan
5
Hello,
I tried the new code you provided and that is also not hiding the div. 
Thanks.