$("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 checkbox.checked總是返回false
的HTML可能是正確的,但你需要將其添加到您的問題。 – j08691
檢查這可能會幫助你http://api.jquery.com/attr/ – Charles380
'checked'不是一個jQuery對象的屬性 – crush