当文本值大于$40时为模态-jQuery



我正试图解决Stefano Zanella在此处链接中回答的一个问题。文本输入值大于。。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();
    }        
});   

使用.replacement():

$("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();
    }        
});

最新更新