Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1256
  • Last Modified:

Make div disappear after a few seconds

I'm using the following script that displays a div for a few seconds and then it disappears. I would like it to ease away more gracefully than the current script I'm using. Can this be done in Jquery and if so, how can I apply it to the following code.

<script type="text/javascript">
// close the div in 5 secs
window.setTimeout("closeHelpDiv();", 5000);

function closeHelpDiv(){
document.getElementById("helpdiv").style.display=" none";
}
</script>


<%
If Request.QueryString("Update")="Success" Then
%>
   <div id="helpdiv" class="corners">
    <img src="../images/Icons/changes_saved.png" width="171" height="50"/>
    </div>        
<%end if
%>
0
swaggerking
Asked:
swaggerking
  • 2
  • 2
1 Solution
 
kadabaCommented:
document.getElementById("helpdiv").style.display=" none";
instead
$("helpdiv").hide('slow');
0
 
swaggerkingAuthor Commented:
kadaba:
Is this what you mean?

<script type="text/javascript">
// close the div in 5 secs
window.setTimeout("closeHelpDiv();", 8000);

function closeHelpDiv(){
$("helpdiv").hide('slow');
}
</script>

If so, it now not disappearing at all.
0
 
kadabaCommented:
$("#helpdiv").hide('slow'); missed the #

sample code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    window.setTimeout("closeHelpDiv();", 8000);
  });

	function closeHelpDiv(){
		$("#helpdiv").hide('slow');
	}
  </script>
	<style type="text/css">
	#helpdiv{
	color:green;
	background-color:yellow;
	}
	</style>
</head>
<body>
	<div id="helpdiv">
		This is the help div i want to hide.
	</div>
</body>
</html>

Open in new window

0
 
swaggerkingAuthor Commented:
Worked like a charm. Much appreciation!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now