jquery append elements until they will reach certain amount -
i have <ul> , want append <li> elements until reach amount of 10
how best practice in jquery?
it great if solution can consider can have example 5 <li>, in case want append 5 more elements reach amount of 10...
you can while loop
while(!$('li:gt(9)').length){ $('ul').append('<li></li>'); } just use :gt() see if eleventh element exists yet or not.
Comments
Post a Comment