I'd like to use jQuery.scroll to display a shadow when user scrolldown in a div (and hide this shadow if scrollbar is on top). It works very well here : http://jsfiddle.net/C4S6s/.
When I put this div in a template it doesn't work :( I'm not so familiar with templates so maybe I miss something.
<script>$(".main-scroll-area").scroll(function () {
var div = $(this);
if (div.scrollTop() == 0)
{
$('.header-shadow').removeClass('shadow-scrolled');
} else {
$('.header-shadow').addClass('shadow-scrolled');
}
});
ADDITIONAL INFORMATION
Here is the css for the shadow:
.shadow-scrolled {
-webkit-box-shadow:0 2px 2px -1px rgba(0,0,0,.6);
-moz-box-shadow:0 2px 2px -1px rgba(0,0,0,.6);
box-shadow:0 2px 2px -1px rgba(0,0,0,.6);
}
Here is the template code that doesn't work. I use also the jQuery that I wrote above to show or hide the shadow.
<script type="text/template" id="MeetingView">
<section class="middle-column" style="background: none repeat scroll 0 0 white;bottom: 0;left: 239px;overflow: hidden;padding: 20px 0 0;position: absolute;right: 381px;top: 42px;">
<div class="header-shadow" style="background-color: #FFFFFF;height: 61px;position: relative;width: 100%;z-index: 9;">
</div>
<div class="main-scroll-area" style="bottom: 0;left: 0;overflow: auto;padding-left: 20px;position: absolute;right: 0;top: 81px;height: 200px;width: 200px;">
this is my content<br />
when scrolldown, shadow appears<br />
when scrollbar at 0, shadow disappears<br />
this is my content<br />
when scrolldown, shadow appears<br />
when scrollbar at 0, shadow disappears<br />
this is my content<br />
when scrolldown, shadow appears<br />
when scrollbar at 0, shadow disappears<br />
</div>
</section>