Skip to content

Instantly share code, notes, and snippets.

@yitsushi
Forked from droid242/DIVrefresh
Created August 25, 2012 20:20
Show Gist options
  • Save yitsushi/3470545 to your computer and use it in GitHub Desktop.
Save yitsushi/3470545 to your computer and use it in GitHub Desktop.
DIV refresh
<!DOCTYPE html>
<html lang="hu">
<head>
<title>DIV refresh page</title>
<meta charset="utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
// en jobban szeretem a jQuery format mint a jQuery-et
// mert igy kisebb az esely hogy osszeakad massal :)
// global valtozositjuk az auto_refresh valtozot
var auto_refresh;
// letrehozzuk a fuggvenyt, hogy ne ketszer irjuk le ugyan azt
var reloadContent = function() {
jQuery('#panel').fadeOut('slow').fadeIn('slow');
};
// jQuery(function() {}) fuggveny csak akkor fut le ha mar kesz a DOM
// jQuery(function() {}) egyenlo a $(function() {}) formaval
jQuery(function() {
jQuery("#changePanel").click(reloadContent);
auto_refresh = setInterval(reloadContent, 4000);
});
</script>
<style type="text/css">
div {
padding: 1em;
background-color: #00c000;
}
input {
padding: .25em 1em;
}
</style>
</head>
<body>
<div id="panel" class="fixie"></div>
<input id="changePanel" value="Change Panel" type="button"><br />
<!--a href="#" id="changePanel">click</a-->
<script type="text/javascript" src="https://raw.github.com/ryhan/fixie/master/fixie_min.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment