Dynamically select the value of a select item javascript/jquery -
i have select list of options, , when user selects 1 of options, want dynamically select same option on similar select list on page.
so these 2 lists:
<select id='b_orientation'><option>horizontal</option><option>vertical</option></select> <select id='orientation'><option>horizontal</option><option>vertical</option></select>
now after user changes b_orientation
, want orientation
mirror change. relevant line of code that:
$('#orientation').val($('#b_orientation'));
but doesn't make difference orientation
. why not?
you forgot mention val()
as of adding element
not element's value
.
change line
$('#orientation').val($('#b_orientation').val());
Comments
Post a Comment