Inline input type="submit"按钮似乎重叠在onclick上

Inline input type="submit" buttons seem to overlap onclick

本文关键字:quot 重叠 onclick submit input type Inline 按钮      更新时间:2023-09-26

在以下示例页面中:

http://thevioletvixen.com/authentic-corsets/flowered-brocade-curves-green/

我有"BUY NOW"answers"SIZING HELP"按钮包含在以下代码中:

<div id="container">
   <div style="float: left; width: 20%; margin-top: 5px; margin-right: 10px;">    
       <input type="submit" class="btn add-to-cart AddCartButton" value="BUY NOW" />
   </div>    
   <div style="float: right; width:20%; margin-top:5px;">
        <input type="submit" class="btn add-to-cart AddCartButton sizingHelp" value="Sizing Help" onclick="AddShoppersWidget.API.User.track('Find_size_btn_clicked'); window.location.href='http://thevioletvixen.com/sizing-help/';">
   </div>
</div>   
<div class="clear"></div>

但是,当试图点击"size HELP"按钮时,显示"BUY NOW"按钮的错误信息,因为没有选择尺寸或选项。

怎么会有这个干扰错误?我试图破解这个解决方案,所以可能有一个更好的方法,让每个按钮内联,而不是包含在一个div,如果这是导致问题?

感谢您的帮助和建议。

就像@MaxMastalerz在他的评论中说的,你可能在两个按钮上都有一个click事件。

例如,如果你有这样的内容:

$(".add-to-cart").click(function() {
    if(/* no size or options have been selected */) {
        alert("Error: No size or options have been selected.");
    }
});

确保为点击寻找事件侦听器,并查看触发它的原因(即,它是$(".add-to-cart")$(".btn")之类的东西,因为它们都存在于两个按钮中?)并确保将其特定于"立即购买"按钮。

希望这对你有帮助!

编辑:正如@AdityaPonkshe在他们的评论中所说,这不是HTML/CSS错误。使按钮内联不会与它们的单击事件有任何关系。