我在Blogger.com上有一个博客,我想添加一个Scroll Triggered Box,如Dreamgrow或Qoate Scroll Triggered Box of Wordpress。我提到Scroll Triggered Box with jQuery。我已经创建了一个HTML文件并对其进行测试,但这对我不起作用。可能是我在某个地方弄错了。我的编码是
<html>
<head>
<title>Scroll Triggered Box With jQuery</title>
<style type="text/css">
.Comments
{
font:georgia;
display:none;
}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$(window).scroll(function () {
var y = $(window).scrollTop();
var c = $('#comments').offset();
if (y > (c.top - $(window).height())) {
$('#the_box').fadeIn("slow");
} else {
$('#the_box').fadeOut('slow');
}
});
});
</script>
<div>
<!--My long post here-->
</div>
<div class="Comments" id="the_box">
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments
</div>
</body>
</html>
我在jScript方面很弱。我不知道jScript是如何工作的。
如何在Blogger.com博客中解决我的问题并使其正常工作?
答案 0 :(得分:0)
我可以告诉你的代码是乱七八糟的。
var a =$(window).height();
var num = c-y;
if (y > num){
do your function
}else{
do whatever
}