Sunday, 15 April 2012

increment - How to increase number count and display on dynamically added div jquery? -



increment - How to increase number count and display on dynamically added div jquery? -

i have link on top of static div loading default (div number 1).

as image illustrates, whenever clicking on hyperlink div added underneath every lastly div did well. want is, can see in picture, have increment count of div numbers 2, 3, 4 along text called 'div number... ' on dynamically added divs.

how can accomplish using jquery?

it pretty straightforward. append new divs.

(function(){ var div = 0; $(".create").click(function(){ div++; $(".block").append('<div class="new_div">div number '+div+'</div>'); }); })();

as demo : click here

jquery increment

No comments:

Post a Comment