Monday, 10 March 2014

Add Dynamic table in jQuery

Add Dynamic table in jQuery
Script
---------
var html = [], $list = $('#myList');
html.push('<div>');
$list.find('li').each(function() {
html.push('<ul><li>' + $(this).text() + '<li></ul>');
});
html.push('</div>');
$list.replaceWith(html.join(''));
Html
<ul id="myList">
<li>test 1</li>
<li>test 2</li>
<li>test 3</li>
<li>test 4</li>
</ul>