Share on Google+Share on Google+

The scroll browser event of jQuery

Advertisement
In this tutorial ,we will print message on browser's window scrolling using scroll browser event of jQuery.

The scroll browser event of jQuery

In this tutorial ,we will print message on browser's window scrolling using scroll browser event of jQuery. In this example, some paragraphs are written , when we scroll down, a message will be displayed in line with the paragraphs.

scrollBrowserEvent.html

<!DOCTYPE html>
<html>
<head>
<style>
div { color:red; }
p { color:blue; }
span { color:red; display:none; }
</style>
<script src="jquery-1.4.2.js"></script>
</head>
<body>
<div>Try scrolling the iframe.</div>
<p>Try to scroll this paragraph - <span>It's Scrolling now!</span></p>
<script>
$("p").clone().appendTo(document.body);
$("p").clone().appendTo(document.body);
$("p").clone().appendTo(document.body);
$("p").clone().appendTo(document.body);
$("p").clone().appendTo(document.body);
$("p").clone().appendTo(document.body);
$(window).scroll(function () {
$("span").css("display", "inline").fadeOut("slow");
});

</script>
</body>
</html>

OUTPUT

Before scrolling :

After scrolling :

Download Source Code

Click here to see demo

Advertisements

Posted on: August 5, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.