[英]Update all table dropdown list items on click
I want to add a button to the column when clicked would set all other dropdown items on the current page to the selection made. 我想在单击时向该列添加一个按钮,以将当前页面上的所有其他下拉菜单项设置为所做的选择。
<select class="select2 select2-offscreen" id="id[0]" name="id[0]">
<option value="not received">Not Received</option>
<option value="received">Received</option>
</select>
<select class="select2 select2-offscreen" id="id[1]" name="id[1]">
<option value="not received">Not Received</option>
<option value="received">Received</option>
</select>
<select class="select2 select2-offscreen" id="id[2]" name="id[2]">
<option value="not received">Not Received</option>
<option value="received">Received</option>
</select>
<button class="go-btn" type="submit">Update All</button>
JS: JS:
$('.go-btn').click(function() {
$("select option").each(function() {
//how to update the dropdow?
});
});
Is this what you are looking for? 这是你想要的? https://jsfiddle.net/zmbagh9h/3/
https://jsfiddle.net/zmbagh9h/3/
var lastSelectedValue = 'not received';
$('select').change(function() {
lastSelectedValue = this.value;
});
$('.go-btn').click(function() {
$('select').val(lastSelectedValue);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.