Error in jquery paging

Posted by Klbaiju under jQuery on 5/21/2015 | Points: 10 | Views : 366 | Status : [Member] | Replies : 1
Hi ,

I want to make clientside paging in my application.

following is working fine in my application

var cnt=4;

var $pagenumbers = $('<div id="pages"></div>');
for (i = 0; i < cnt; i++) {
$(' <a href=\"#\" id=' + (i + 1) + ' class="page">' + (i + 1) + '</a>').appendTo($pagenumbers);
}
$pagenumbers.insertAfter('#st');

this will display 1 2 3 4.

my requirement is add anchor with << and >> symbols before and after paging numbers like << 1 2 3 4 >> .

for that i tried following code

var cnt=4;

var $pagenumbers = $('<div id="pages"></div>');
for (i = 0; i < cnt; i++) {
$(' <a href=\"#\"> '<<'</a> <a href=\"#\" id=' + (i + 1) + ' class="page">' + (i + 1) + '</a> <a href=\"#\"> '>>'</a>').appendTo($pagenumbers);
}
$pagenumbers.insertAfter('#st');

But this is not working .how to solve this

Regards

Baiju




Responses

Posted by: Jitendrasoft09 on: 5/23/2015 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi,

Ideally you should define the variable and loop into that and append that assigned variable. It could be the issue of concatenation of the appended page numbers. Refer below link-
http://stackoverflow.com/questions/2523075/generate-page-numbers-using-javascript-jquery

Jitendra Kumar
If my post helps you, plz mark as an answer.

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response