嗨,我在jquery中有这个更改功能,当选择时间时,时间将计算为四个小时。选择使用更改功能后,时间和四小时的计算效果很好。现在我的问题是如何将值传递给我的 .html()
下面是我的脚本:
$('#changeTime').change(function() {
$("#checkoutT").hide();
var time = $(this).val();
var timeArr = time.split(":");
var timevar = timeArr[0];
var x = <?php echo $minStayExp[0] ?>;
var calc = parseInt(timevar) + parseInt(x);
console.log(timevar);
console.log(calc);
alert(calc);
$("#checkoutTime").html('<p class="text-sm text-muted"></p>');
});
现在我希望我的 var calc
中的 value
将传递到这里的 .html()
代码行:
$("#checkoutTime").html('<p class="text-sm text-muted"> + calc +</p>');
类似这样的事情。
有人可以帮我解决这个问题吗?非常感谢任何帮助。 TIA
最佳答案
您需要连接。
$("#checkoutTime").html('<p class="text-sm text-muted">' + calc +'</p>');
关于javascript - 如何使用 javascript 将值从变量传递到 .html(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59289311/