Reputation: 1
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>
Upvotes: 0
Views: 649
Reputation: 8053
Do it directly in the creation of your viewmodel:
function MyViewModel(){
this.addtocart = function(){
//Some code
}
this.addtocart(); // <-- here
}
Upvotes: 3
Reputation: 105
you can add a ready function in your javascript like this..
<script>
$("document").ready(function () {
window.getElementById("redeemButton").click();
});
</script>
Upvotes: 0