0

I have some jQuery code, which attempts to show the first 6 divs on page load and hide all of the others. It is littered with errors, but ideally I am trying to create a function that shows the next six divs on an event, ultimately when the user scrolls to the bottom. I know my code is not great, but I have done my best to make it as easy to follow as possible.

The code is here, and any help would be much appreciated! Thanks in advance

4

3 回答 3

1

replace

for (i = contentNumber, i < constraintNumber, i++;) {

by

for (i = contentNumber; i < constraintNumber; i++) {

in javascript (and C), ; must separate the 3 elements of a for statement

in jsfiddle, you have 'JSLint' button to verify code error !! Use it !

于 2012-04-06T10:31:45.927 回答
1

Here http://jsfiddle.net/gRzPF/7/ I modified your code, now it seems to work :)

于 2012-04-06T10:42:35.403 回答
1

I think this is what you wanted:

http://jsfiddle.net/gRzPF/8/

If I understand correctly every time you get to the bottom of the window you want to show the next 6 divs. My edit achieves that.

You just needed to use semi-colons in your for statement, wrap a function around it and move your constraintNumber variable inside that function.

于 2012-04-06T10:46:46.777 回答