JQuery create new select option

Posted by nav on Stack Overflow See other posts from Stack Overflow or by nav
Published on 2010-05-04T17:37:43Z Indexed on 2010/05/04 17:48 UTC
Read the original article Hit count: 128

Hi

I have the below functions in regular javascript creating select options. Is there a way I can do this with JQuery without having to use the form object?

function populate(form)
{
form.options.length = 0;
form.options[0] = new Option("Select a city / town in Sweden","");
form.options[1] = new Option("Melbourne","Melbourne");
}

Below is how I call the function above:

populate(document.form.county); //county is the id of the dropdownlist to populate.    

Many Thanks,

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors