It seems that I can not cause a change in my list after changing the selected value in the code. The change function works fine if you actually clicked the list. I searched the forums and none of the solutions seem to work for me. The following is sample code. I also created jsfiddle here . I want it to go into the change function when the code runs.
<form> <select class="selectOneListBox" id="CompanyId" multiple="multiple" name="CompanyId"> <option value="1">Test</option> <option value="2">Test 2</option> <option value="3">Test</option> </select> <form>
$(function () { id = 3 if (id > 0) { alert(id) $('#CompanyId').val(id).change(); } }); $("#CompanyId").change(function () { alert("change"); });
source share