Dynamic HTML5 Datalist
I know this answer is late but it might help someone.
var nameArray = ["Rick Bross","Madison Smith","Jack Johnson"];
Add options to the datalist.
- "attr" helps if you need an i.d to identify each option.
- "text" is the content to be displayed.
$.each(nameArray, function(i, item) {
$("#potentials").append($("<option>").attr('value', i).text(item));
});
There was a missing apostrophe, try:
$('#potentials').append("<option value='" + nameArray[i] + "'>");