Browse - Programming Tips - What's the best way to append an option to a select with jQuery?

Date: 2011dec8
Platform: web
Libary: jQuery
Language: javaScript

Q.  What's the best way to append an <option> to a <select> with jQuery?

A.  This function does it

function selectAppend(jquerySearch, myvalue, pretty) { $(jquerySearch).append($('<option>', { value : myvalue }).text(pretty)); }
Example use:
selectAppend('#myselect', '1.00', 'One Dollar');