jQuery scroll event

Опубликовано: 06 Май 2015
на канале: kudvenkat
69,491
312

Link for all dot net and sql server video tutorial playlists
https://www.youtube.com/user/kudvenka...

Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
   / @aarvikitchen5572  

In this video we will discuss scroll event and how to handle it using jQuery.

scroll event is raised when the user scrolls to a different place in the element. It applies to window objects, but also to scrollable frames and elements with the overflow CSS property set to scroll.

In the following exampe, notice that the div element overflow style is set to scroll. The div element has a scrollbar and as you scroll up and down the div element, the scroll event is raised and handled.

Replace < with LESSTHAN symbol and > with GREATERTHAN symbol

<html>
<head>
<title></title>
<script src="jquery-1.11.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('div').scroll(function () {
$('h3').css('display', 'inline').fadeOut(1000);
});
});
</script>
</head>
<body style="font-family:Arial">
<div style="width:300px; height:200px; border:1px solid black; overflow:scroll">
PRAGIM Speciality in training arena unlike other training institutions. Training delivered by real time software experts having more than 10 years of experience. Interview questions and real time scenarios discussion on topics covered for the day. Realtime projects discussion relating to the possible interview questions. Trainees can attend training and use lab untill you get a job. Resume preperation and mock up interviews. 100% placement assistance. 24 hours lab facility. PRAGIM Technologies offers professional real time projects for studetns in their final semester. Course completion and project completion certificates will also be provided upon successful completion of the course. We have partnered with major multinational companies to place freshers with our clients on their course completion.
</div>
<br />
<h3 style="display:none; color:red">Scroll event handled</h3>
</body>
</html>

The following example, keeps track of how many times the scroll event is raised.

<html>
<head>
<title></title>
<script src="jquery-1.11.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var count = 0;
$('div').scroll(function () {
$('span').text(count += 1);
});
});
</script>
</head>
<body style="font-family:Arial">
<div style="width:300px; height:200px; border:1px solid black; overflow:scroll">
DIV CONTENT
</div>
<br />
<h3 style="color:red">Scroll event handled <span>0</span> time(s)</h3>
</body>
</html>

The following example, keeps track of whether the user scrolled up or down.

<html>
<head>
<script src="jquery-1.11.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var lastScrollTop = 0;
$('div').scroll(function () {
var currentScrollPosition = $(this).scrollTop();
if (currentScrollPosition > lastScrollTop) {
$('h3').text('You scrolled down');
} else {
$('h3').text('You scrolled up');
}
lastScrollTop = currentScrollPosition;
});
});
</script>
</head>
<body style="font-family:Arial">
<div style="width:300px; height:200px; border:1px solid black; overflow:scroll">
DIV CONTENT
</div>
<br />
<h3 style="display:inline; color:red"></h3>
</body>
</html>


На этой странице сайта вы можете посмотреть видео онлайн jQuery scroll event длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь kudvenkat 06 Май 2015, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 69,491 раз и оно понравилось 312 зрителям. Приятного просмотра!