2 回答
TA贡献1799条经验 获得超9个赞
只需将值分配给 即可select。
//var customerID = window.location.hash;
var customerID = "6a1920b2-f388-4790-a720-75048e1407a7"; //Test User 5
//$('#customer-dropdown option[value="'+ customerID +'"]').prop('selected', true);
//$("#customer-dropdown select").val(customerID);
$("#customer-dropdown").val(customerID);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="customer-dropdown" name="c15905d7-8216-4e81-ac15-2fafd10b49e8">
<option disabled="">Select Customer</option>
<option value="297f8676-80bf-43e5-b463-031a5b5154aa">Test User 1</option>
<option value="83941899-8039-488f-bf6b-0d036c7d6556">Test User 2</option>
<option value="263356fd-d803-4436-a7fc-4df5a3095771">Test User 3</option>
<option value="2e31ee49-b096-4237-b07e-61071871334d">Test User 4</option>
<option value="6a1920b2-f388-4790-a720-75048e1407a7">Test User 5</option>
<option value="072f6800-570c-4004-b9cd-7bdb4cf98b0a">Test User 6</option>
<option value="c957f2c0-f72e-4de7-9b4f-9272cbbfd783">Test User 7</option>
<option value="d870225f-c020-4369-bd7b-9dc5d16f34a1">Test User 8</option>
</select>
TA贡献1909条经验 获得超7个赞
只需将值分配给 即可select。
//var customerID = window.location.hash;
var customerID = "6a1920b2-f388-4790-a720-75048e1407a7"; //Test User 5
//$('#customer-dropdown option[value="'+ customerID +'"]').prop('selected', true);
//$("#customer-dropdown select").val(customerID);
$("#customer-dropdown").val(customerID);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="customer-dropdown" name="c15905d7-8216-4e81-ac15-2fafd10b49e8">
<option disabled="">Select Customer</option>
<option value="297f8676-80bf-43e5-b463-031a5b5154aa">Test User 1</option>
<option value="83941899-8039-488f-bf6b-0d036c7d6556">Test User 2</option>
<option value="263356fd-d803-4436-a7fc-4df5a3095771">Test User 3</option>
<option value="2e31ee49-b096-4237-b07e-61071871334d">Test User 4</option>
<option value="6a1920b2-f388-4790-a720-75048e1407a7">Test User 5</option>
<option value="072f6800-570c-4004-b9cd-7bdb4cf98b0a">Test User 6</option>
<option value="c957f2c0-f72e-4de7-9b4f-9272cbbfd783">Test User 7</option>
<option value="d870225f-c020-4369-bd7b-9dc5d16f34a1">Test User 8</option>
</select>
- 2 回答
- 0 关注
- 131 浏览
添加回答
举报