tags:

views:

25

answers:

2

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</option>
<option value="0">All</option>

+1  A: 
$('#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.
Reigel
+2  A: 

Several methods are there. You can use

$('<option value="5">item 5</option>').appendTo('#listbox');

$('#listbox').append('<option value="5">item 5</option>');
Joyce Babu