close
「Javascript TensorFlow.js人工智慧應用教本」一書中之程式
Ch11_4_2.html
課本11-20
程式內容 15行之內容
if ($('#discount').attr('checked')) {
amount = (price * quantity) * 0.9;
amount = amount.toFixed(2);
}
應改成is(':checked')或是prop('checked'))
//if ($('#discount').is(':checked')) {
if ($('#discount').prop('checked')) {
amount = (price * quantity) * 0.9;
amount = amount.toFixed(2);
}
原因是attr 傳回值是'checked'而不是true or flase
全站熱搜