2
我有选择和一些输入(范围+文本)。我需要做的是当我选择一个选择,输入获取值,但代码只适用于第一选择。当我改变我的选择的价值并没有改变。我应该纠正什么?jQuery如果选择选项标签= ...设置输入值
$(document).ready(function() {
$("div.roword select").change(function() {
var text = $(this).find("option:selected").text();
if (text = "60x90") {
$("input#height, input#heightPlus").attr('value', '60');
$("input#width, input#widthPlus").attr('value', '90');
$("input#height, input#width").focus();
$("input#height, input#width").blur();
} else
if (text = "100x150") {
$("input#height, input#heightPlus").attr('value', '100');
$("input#width, input#widthPlus").attr('value', '150');
$("input#height, input#width").focus();
$("input#height, input#width").blur();
} else
if (text = "120x180") {
$("input#height, input#heightPlus").attr('value', '120');
$("input#width, input#widthPlus").attr('value', '180');
$("input#height, input#width").focus();
$("input#height, input#width").blur();
}
});
});
使用''== /''===比较运算,而不是'='赋值运算符中,如果块即'文本=== “100x150”'并设置值使用'.val()'方法,即'$(“input#width,input#widthPlus”).val(90)' – Satpal