开发者

jQuery check box question

开发者 https://www.devze.com 2023-01-25 19:18 出处:网络
how can I make the 5th box work with \"checked\" or \"not checked\"? var price_1_startup = 800; var price_1 = 0;

how can I make the 5th box work with "checked" or "not checked"?

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);" chec开发者_JAVA百科ked="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>


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

This will get you the currently check radio button value (1, 2, 3, 4)

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

精彩评论

暂无评论...
验证码 换一张
取 消