add item to a listbox using jquery
How to add item to a listBox using jquery.
for example in the following listbox
<option value="1"></option>
<option value="2">item 2</option>
<option value="3">item 3</option>
<option value="4">item 4</opti开发者_运维百科on>
<option value="0">All</option>
$('#Select1').append('<option value="5">item 5</option>'); // adds item 5 at the end
$('#Select1 option').eq(0).after('<option value="new">new</option>'); // add new at the second position.
Several methods are there. You can use
$('<option value="5">item 5</option>').appendTo('#listbox');
$('#listbox').append('<option value="5">item 5</option>');
精彩评论