views:

29

answers:

2
 $('input[name="iplus"]').click(function() {  

    $("#billsumary").append("<li>Test</li>");

}); 

Hi,

i append a li-elemnt on every click. Now I like to wrap all those created li-elements into an ol-element but not each created one but all of them together.

sample html output:

<div id='billsumary'>
<ol>
 <li>Test</li>
 <li>Test</li>
 <li>Test</li>
  ...
 <li>Test</li>
</ol>
</div>
A: 
$('#billsumary > li').wrapAll('<ol></ol>');

jQuery.wrapAll API docs

Matt Ball
A: 

You probably want do create the <ol> at the beginning, and append new elements to it:

var ol = $('<ol />').appendTo("#billsumary");

$('input[name="iplus"]').click(function() {  
    $(ol).append("<li>Test</li>");
}); 
Kobi
@Kobithx thats it – lesson learned :)
Don