开发者

JQuery pagination plugin showing strange results

I am building a pagination plugin and I am having the strangest results. here is a demo

If you click on the next button (>>) you will be taken to the last page. But, if you click on the prev button (<<) before you click on the next button you will be taken to the proper page.

Ohh, and if you click on a page number then the next button you will always be taken to the last page.

I've been staring at it for a bit 开发者_运维百科now. boggles me.


It's because this line return a string:

 var _to = $(this).attr("id");

So that string eventually makes it's way into current_to and when you write current_to + $options.items_pp you get a string like 1010 instead of 20.

Just change the line to:

var _to = parseInt($(this).attr("id"), 10);

Or even better:

var _to = parseInt(this.id, 10);

JSFiddle

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜