Sort div using javascript

Hi all,

This is my first topic in sitepoint forum.

I am creating dynamic div & button for pagination using javascript. My question when i enter the value in the text box the number of div was creating but it was not sorting 1,2,3… It was sorting like 2,1.

Here is the fiddle Link.

Kindly help me on sorting.

Thanks in Advance

When I put in 10, it creates ten buttons in a nicely sorted.

When I put in 2 and then 1, it ends up with 3 in the proper order.

Can you please instruct us further on how to experience the problem that you are having.

If you enter the number 10 I am creating 10 divs. If you see the page number right bottom div page it starting from 10,9,8… but I want from 1,2,3,4,5…

You should just need to reverse your for loop.

for (var j = count; j > 0; --j)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.