I'm trying to add my select options into a select box when the user clicks an image. The image opens up a hidden search div containing the box. I have the following code:
html
<select id="search_state" name="state" class="large">
</select>
jquery
$(document).ready(function(){
$('.search').click(function() {
$('#search_state').append('<optgroup label="Chile"><option value="907">Región Metropolitan</option></optgroup><optgroup label="China"><option value="1355">Guangdong</option><option value="1353">Hainan</option><option value="1341">Jiangsu</option><option value="1307">Shanghai</option></optgroup><optgroup label="Costa Rica"><option value="1037">Alajuela</option><option value="1041">Guanacaste</option><option value="1043">Heredia</option><option value="1047">Puntarenas</option><option value="1049">San José</option></optgroup>');
alert("works");
});
});
The image class is .search, and the selectbox ID is #search_state. For some reason I can't get the selectbox to append, but the alert works onclick. Even when the box is hidden, its still listed under the source code. Does anyone know why I'm having this issue?