gpt4 book ai didi

javascript - 如何在knockout js中自动点击按钮

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

我的页面上有以下按钮。我希望加载此页面时自动单击下面的按钮。我尝试遵循网上的各种建议,但无法找到解决方案。如有任何帮助,我们将不胜感激。

 <a data-bind="click: $root.addtocart" class="w-button btn-large" 
style="text-decoration: none!important;" id="redeemButton">
Redeem Now
</a>

最佳答案

直接在创建 View 模型时执行此操作:

function MyViewModel(){
this.addtocart = function(){
//Some code
}
this.addtocart(); // <-- here
}

关于javascript - 如何在knockout js中自动点击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42362731/

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