<script type="text/javascript">
$(document).ready(function() {
var sub_total = $("sub_total").text();
alert(sub_total);
var ship_total = $("ship_total").val()
alert(ship_total);
var new_total = sub_total + ship_total;
$('#new_total').html( new_total.toFixed(2));
});
</script>
出力をテストするためにアラートを使用していますが、スパン ID 内の値を取得していません。
$<span id="sub_total"><?php echo $sub_total = number_format($this->cart->total(), 2); ?></span></td>
これはページに正しく表示されますが、アラートは空白のボックスです。値new_total
が数値でNaN
はない状態になる。
これら 2 つのフィールドに値を追加するにはどうすればよいですか?