Я хочу, чтобы этот скрипт выполнялся всякий раз, когда пользователь прокручивает второй div. Второй div в смысле «content» div. Первый div - это заголовок. Сценарий анимации On-Scroll.Сценарий анимации On-Scroll. Он работает только один раз
<!doctype html>
<head>
<script type="text/javascript">
$(document).ready(function(){
$('.content').scroll(function(){
if ($(this).scrollTop() > 100)
{
$(".header").animate({"height": "300px"},"slow");
}
else
{
$(".header").animate({"height": "100px"},"fast");
}
});
});
</script>
<style>
body{
margin:auto;
overflow:hidden;
background-color:#000;
}
.outer{
width:800px;
border:thin solid;
height:900px;
background-color:#fff;
margin:auto;
}
.wrapper{
width:800px;
position:relative;
z-index:100;
height:900px;
}
.header{
width:800px;
height:300px;
border: thin solid #F00;
background-color:#666;
}
.content{
width:800px;
height:600px;
overflow:scroll;
}
</style>
</head>
<body>
<div class="outer">
<div class="wrapper">
<div class="header"></div>
<div class="content">
<p>Dummy content so that the content makes the div to scroll.</p>
</div>
</div>
</div>
</body>
</html>
Сценарий должен запускаться всякий раз, когда пользователь прокручивает div.
Можете ли вы предоставить [jsfiddle] (http://jsfiddle.net/), пожалуйста? – MisterJ
или html, чтобы перейти с вышеуказанным – Pete
Привет, Пит. Я добавил коды html и css. Спасибо за ответ ур. – Ravi