gpt4 book ai didi

javascript - Jquery checkbox.checked 总是返回 false

转载 作者:搜寻专家 更新时间:2023-11-01 04:45:59 24 4
gpt4 key购买 nike

$("tbody input[name='rooms_to_book']").on('change',function(){
var current_row = $(this).closest("tr");
var current_checkbox = current_row.find("input[name=checkbox]");
if(current_checkbox.checked) {
var price_per_night = parseFloat(current_row.find("td[name=price]").text().replace('$',''));
var rooms_to_book = parseInt(current_row.find("input[name=rooms_to_book]").val());
rooms_to_book = rooms_to_book ? rooms_to_book : 0;
total_price = price_per_night * rooms_to_book;
}else{
total_price = 0;
}
current_row.find("td[name=total_price]").text('$'+ total_price);
});

current_checkbox.checked 总是返回 false,html 是正确的。

最佳答案

jQuery 对象没有 checked 属性。替换

current_checkbox.checked

current_checkbox.prop('checked')

http://api.jquery.com/prop

关于javascript - Jquery checkbox.checked 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21120532/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com