Jquery Replace Select Options -


this question has answer here:

i looking replace current select options set of option without using loop. have block of code:

<select> <option>o1</option> <option>o1</option> </select> 

i have variable:

$newoptions = "<option>newo1</option>                <option>newo1</option>"; 

and want swap inside of select state new options. no loop needed.

<select>     $newoptions </select> 

is there way using jquery?

$('selectoptions[name='+fldname+']').replacewith(newoptions); 

thank you.

try way:

<select id='needselect'>   <option>o1</option>   <option>o1</option> </select>  $newoptions = "<option>newo1</option>                <option>newo1</option>";  $('select#needselect').html($newoptions); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -