如何在淘汰赛JS中自动单击按钮 [英] How to auto click button in knockout js
本文介绍了如何在淘汰赛JS中自动单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面上有以下按钮.我希望在加载此页面时自动单击下面的按钮.我尝试遵循网上的各种建议,但找不到解决方案.感谢您的帮助.
I have the below button on my page. I want below button to be auto clicked when this page gets loaded. I've tried following various suggestions on the net but I'm unable to find a solution. Any help is appreciated.
<a data-bind="click: $root.addtocart" class="w-button btn-large"
style="text-decoration: none!important;" id="redeemButton">
Redeem Now
</a>
推荐答案
在创建视图模型时直接执行以下操作:
Do it directly in the creation of your viewmodel:
function MyViewModel(){
this.addtocart = function(){
//Some code
}
this.addtocart(); // <-- here
}
这篇关于如何在淘汰赛JS中自动单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文