html - Change selected option in jQuery -


my html

<select name="one_day_per_month" id="one_day_per_month" style="width: 200px">   <option value="false" selected>no</option>   <option value="true">yes</option> </select> 

the page wrapped with

$( document ).ready(function() {...} 

i can change value using

$("#one_day_per_month").val("true") 

the value updated, dropdown list not change in browser not change. doing wrong?

try call trigger change achieve requirement.

$( document ).ready(function() {  $("#one_day_per_month").val("true").trigger("change");  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <select name="one_day_per_month" id="one_day_per_month" style="width: 200px">    <option value="false" selected>no</option>    <option value="true">yes</option>  </select>


Comments