jQuery复选框问题

时间:2010-11-15 19:14:33

标签: jquery css-selectors

如何使用“已选中”或“未选中”使第5个框工作?

var price_1_startup = 800;
var price_1 = 0;

function upgrade_1(str) {
    if (str == 1) {price_1 = 0;}
    else if (str == 2) {price_1 = +125;}
    else if (str == 3) {price_1 = +200;}
    else if (str == 4) {price_1 = +325;}
    $("#price_1").hide().html(price_1_startup+price_1).fadeIn('slow');
}
function checkbox() {
    $("#price_1").hide().html(price_1_startup+1500).fadeIn('slow');
}

<input type="radio" name="upgrade1" value="1" onclick="upgrade_1(this.value);" checked="checked" /><br>
<input type="radio" name="upgrade1" value="2" onclick="upgrade_1(this.value);" /><br>
<input type="radio" name="upgrade1" value="3" onclick="upgrade_1(this.value);" /><br>
<input type="radio" name="upgrade1" value="4" onclick="upgrade_1(this.value);" /><br>
<input type="checkbox" name="upgrade1" value="5" onclick="checkbox(this.value);" /><br>

1 个答案:

答案 0 :(得分:0)

jQuery('input[value="5"]').attr('checked', true);

这将为您提供当前检查单选按钮值(1,2,3,4)

var selected = parseInt(jQuery('input[type="radio"][name="upgrade1"]:checked').val());