Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
Nth child jquery not working sharepoint in Errors in jquery of JQuery Examples
3430 Views
Note  
If nth child not working instead of that use eq() function
Same function with eq()
	$(document).ready(function () {
	   var totalrows = $(".divControl").length;
	   var pageSize = 2;
	   var noOfPage = totalrows / pageSize;
	   noOfPage = Math.ceil(noOfPage);
	   for (var i = 1; i <= noOfPage; i++) {
	       $("#divPages").append('<div class="page">' + i + '</div>');
	   }
	   $("div.divControl").hide();
	   for (var j = 0; j < pageSize; j++) {
	       $("div.divControl").eq(j).show();
	   }
	   $("div.page").click(function () {
	       var currentPage = $(this).text();
	       $("div.divControl").hide();
	       for (var k = (currentPage * 2) - 2; k < (currentPage * 2); k++) {
	           $("div.divControl").eq(k).show();
	       }
	   });
	});
Demo 
Same function with nth child
	$(document).ready(function () {
	   var totalrows = $(".divControl").length;
	   var pageSize = 2;
	   var noOfPage = totalrows / pageSize;
	   noOfPage = Math.ceil(noOfPage);
	   for (var i = 1; i <= noOfPage; i++) {
	       $("#divPages").append('<div class="page">' + i + '</div>');
	   }
	   $("div.divControl").hide();
	   for (var j = 1; j <= pageSize; j++) {
	       $("div.divControl:nth-child(" + j + ")").show();
	   }
	   $("div.page").click(function () {
	       var currentPage = $(this).text();
	       $("div.divControl").hide();
	       for (var k = (currentPage * 2) - 1; k <= (currentPage * 2); k++) {
	           $("div.divControl:nth-child(" + k + ")").show();
	       }
	   });
	});
Demo 
Best Lessons of "JQuery Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details