我正在尝试解决 Stefano Zanella 在此处链接中回答的问题。 text input value greater than.. jQuery
当购物车小计金额超过 40 美元时,我需要弹出一个模型。
只要小计中没有美元符号,该代码就可以工作。但是,购物车输出带有美元符号的小计,我不知道如何在调用警报之前将其删除。
<div id="subtotal-alert"">$55.00</div>
<script>
$("input[type='text'][name='subtotal-alert']").change(function() {
if ($(this).val() >= 41) {
alert("To order quantity greater than 40 please use the contact form.");
$(this).val('');
$(this).focus();
}
});
最佳答案
使用.replace():
$("input[type='text'][name='subtotal-alert']").change(function() {
if ($(this).val().replace('$','') >= 41) {
alert("To order quantity greater than 40 please.use the contact form.");
$(this).val('');
$(this).focus();
}
});
关于javascript - 当文本值大于 $40 时的模态 - jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26556616/