Here I will explain how to implement simple div with fadein fadeout, fadeto effects using JQuery in asp.net.
In previous posts I explained Draggable and Resizable example, split the string, add fade in effect to page, Password strength jquery plugin examples and many articles relating to JQuery. Now I will explain how implement simple div with fadein fadeout, fadeto effects in JQuery.
<script type="text/javascript">
$(document).ready(function()
{
$('#fadeindiv').fadeIn('slow');
$('#fadeoutdiv').fadeOut('slow');
$('#fadetodiv').fadeTo('slow', 0.2);
});
</script>
|
<script type="text/javascript">
$(document).ready(function()
{
$('#fadeindiv').fadeIn(2000);$('#fadeoutdiv').fadeOut(2000); $('#fadetodiv').fadeTo(2000,0.2);
});
</script>
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JQuery fadein fadeout and fadeTo effects for div example</title>
<style type="text/css">
.fadediv{
width: 150px; height: 50px; padding: 0.5em;background:#EB5E00;color:#fff;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
</head>
<body>
<form id="form1"
runat="server">
<h2> jQuery fadeIn, fadeOut and fadeTo effects for div Example</h2>
<table>
<tr>
<td>
<div id="fadeindiv"
class="fadediv">
<b>Click me - fadeIn()</b>
</div>
</td>
<td>
<div id="fadetodiv" class="fadediv">
<b>Click me - fadeTo()</b>
</div>
</td>
<td>
<div id="fadeoutdiv" class="fadediv">
<b>Click me - fadeOut()</b>
</div>
</td>
</tr>
<tr>
<td colspan="3"><button
id="btnReset">Reset</button></td>
</tr>
</table>
<script type="text/javascript">
// Applying fadein effect
$("#fadeindiv").click(function() {
$(this).hide().fadeIn('slow');
});
// Applying fadeout effect
$("#fadeoutdiv").click(function() {
$(this).fadeOut('slow');
});
// Applying fadeto effect
$("#fadetodiv").click(function() {
$(this).fadeTo('slow', 0.2);
});
// Reset the div's
$('#btnReset').click(function() {
$('#fadeindiv').fadeIn('slow');
$("#fadeoutdiv").fadeIn('slow');
$("#fadetodiv").fadeIn('slow');
})
</script>
</form>
</body>
</html>
|
|
||||||||
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
2 comments :
nice post
Dear Sir How can we do automatically fadeout div for certain time and again come in. just like www.jobkunja.com.... can u please explain me that