Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy option list from dropdownlist. JQuery

Html code

<select id="dropdwon1">
 <option value="1">Item1</option>
 <option value="2">Item2</option>
 <option value="3">Item3</option>
</select>

<select id="dropdwon2"></select>

I need copy all options from dropdown1 to dropdown2, using jQuery. Whether it is possible to copy contents simply?

like image 305
mola10 Avatar asked Dec 13 '10 21:12

mola10


1 Answers

$('#dropdwon1 option').clone().appendTo('#dropdwon2');

jsfiddle link

like image 57
Josiah Ruddell Avatar answered Oct 15 '22 00:10

Josiah Ruddell