gpt4 book ai didi

javascript - 检查 span 类内容,然后使用 jquery 更新数量?

转载 作者:行者123 更新时间:2023-11-28 10:07:08 27 4
gpt4 key购买 nike

我这里有代码:

//Check current
if (parseInt($("#Quantity").val()) < 25) {
// If it is less than 25 then set it to 25
$("#Quantity").attr("value", "25");
}

它检查数量框是否小于 25,如果是,则在框中添加 25。问题出在特定产品上,我需要检查我的页面是否包含:

<span class="ProductNameText">This is product ABC</span>

这是一个解决方法,因为客户只有 2 种产品,不需要 25 数量。理想情况下,我想检查页面是否包含套件选项表单字段,然后将 25 添加到框中。

关于如何检查跨度然后更新数量的任何想法。但数量不应该是强制的,因此如果用户想要 6 件商品,他们应该能够添加该数字。

最佳答案

  if($('span.ProductNameText').text()=='This is product ABC'){
//Check current
if (parseInt($("#Quantity").val()) < 25) {
// If it is less than 25 then set it to 25
$("#Quantity").attr("value", "25");
}
}

希望我理解您的疑问。

关于javascript - 检查 span 类内容,然后使用 jquery 更新数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8119533/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com