[英]Change value of other options, after selected option
http://fiddle.jshell.net/stealthpancakes/qc8pwsze/3/
我想将所有选项的值更改为“ 0”(选定选项除外)。
例如,如果我首先选择生物学 ,然后选择化学,那么化学和其他选项的值( 生物学除外)应为“ 0”。
因此,我首先选择“ 生物学和化学” ,对于“ level2”,均单击“计算”按钮,然后结果应为:50/100,而不是80/100。
到目前为止,我设法添加了以下代码:
$('select[name*="select-subject"]').change(function() {
$('option').not("option:selected").each(function() {
$(this).val('0');
});
});
也许你应该指定其select
的选项属于:
$('select[name*="select-subject"]').change(function() {
$(this).find('option:not(:selected)').each(function() {
$(this).val('0');
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.