I have an array that I want to have displayed in html.. I don\'t want to write multiple lines for posting each item in the array but all should be exactly the same. ie
here is solution, i create a text field to dynamic add new items in array my html code is
now type any thing in text field and click on button this will add item onto array and call function dispaly_arry
$(document).ready(function()
{
function display_array()
{
$("#names").text('');
$.each(names,function(index,value)
{
$('#names').append(value + '
');
});
}
var names = ['Alex','Billi','Dale'];
display_array();
$('#btn').click(function()
{
var name = $('#name').val();
names.push(name);// appending value to arry
display_array();
});
});
showing array elements into div , you can use span but for this solution use same id .!