I'm using jquery to paginate an HTML table.
I have 2 CSS classes, aPage and thePage, a javascript function that creates a pagination string, and jquery code to bind each "page" to the click event so that the pagination string is calculated when the page is clicked.
My problem is that the click event only fires once, though I want it to fire each time a page is clicked.
Any help is greatly appreciated. Thanks!!
My javascript/jquery code is:
var thisPage=1; npages=10;
//initial pagination
$("#pag").html(showPag(thisPage,npages));
// bind pagination string to click event
$(".aPage").click(function(event){
var thisPage=$(this).text()
$("#pag").html(showPag(thisPage,npages));
});
// function that returns pagination string
function showPag(thisPage,npages) {
p="";
for(i=1;i<=10;i++){
if(i==thisPage) {
p+="<span class='thePage'>"+i+"</span>"
}
else {p+="<span class='aPage'>"+i+"</span>" }
}
return p;
}