user2520464
user2520464

Reputation:

Determine the height that has been scrolled from the top

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.

Upvotes: 0

Views: 33

Answers (2)

Kiran
Kiran

Reputation: 20303

You have typo. Missing "":

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

DEMO FIDDLE

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388436

div is a string literal, not a variable in this case, so you need to enclose it with in ''

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

Demo: Fiddle

Upvotes: 1

Related Questions