Simple hide code not working

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.

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; } );
});

Hello,

Thanks for the help. How to hide the div after 10 seconds ?

Thanks.

Take a look at javascripts setTimeout() function.

Hello,

I tried the new code you provided and that is also not hiding the div. :frowning:

Thanks.