0

My question tells everything. I have already tried the following :-

$(window).scroll(function() {
    var height=$(window).scrollTop(); 
    $(div).html(height); 
});

You can see it live at http://jsfiddle.net/JdXQA/ . But it is not working. Any help will be appreciated. Thanks in advace.

4

2 回答 2

1

div是字符串文字,在这种情况下不是变量,因此您需要用 in 将其括起来''

$('div').html(height); 

演示:小提琴

于 2013-10-11T03:11:21.933 回答
1

你有错字。缺少""

$("div").html(height); 

DEMO FIDDLE

于 2013-10-11T03:11:43.943 回答