gpt4 book ai didi

javascript - WhatsApp 按钮中的 Onclick 功能

转载 作者:行者123 更新时间:2023-11-28 03:02:07 24 4
gpt4 key购买 nike

我在订单按钮中有 onclick 函数,将输入发送到数据库,修改按钮后(将其连接到 WhatsApp 而不是数据库)onclick 函数已停止工作...我需要 onclick 函数即可工作。

<form className="orderForm">
<div className="form-group">
<div className="whatsapp" style="margin-top: 20px;">
<button
className="btn-primary"
onClick="reportConversion(event.target)"
type="submit"
style="height:70px;width: 100%;"
>
<img
src="wat.png"
style="width: 36px;height: 36px; position: absolute; margin-left: -40px;margin-top: -10px;"
/>
<a href="https://wa.me/......" style="color: white;font-weight: 600; font-size: 18px;">
...text...
</a>
</button>
</div>
</div>
</form>

最佳答案

使用Promse将是一个很好的解决方案,但是reportConversion返回未知,也不确定我们可以修改它吗?

无论如何,由于我们有链接优先级,这个解决方案可能适合。

注意:记得修改<button>输入 submitbutton并从内部删除链接。

function reportConversionWrapper(target) {
reportConversion(target);
setTimeout( function() {
window.location.href = 'https://wa.me/......';
}, 1000 );
}
// following is just a filler - don't mind it
function reportConversion(a) {
return;
}
<form className="orderForm">
<div className="form-group">
<div className="whatsapp" style="margin-top: 20px;">
<button
className="btn-primary"
onclick="reportConversionWrapper(event.target)"
type="button"
style="height:70px;width: 100%;"
>
<img
src="wat.png"
style="width: 36px;height: 36px; position: absolute; margin-left: -40px;margin-top: -10px;"
/>...text...
</button>
</div>
</div>
</form>

关于javascript - WhatsApp 按钮中的 Onclick 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60899929/

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