The below mentioned code loads a page with a buy the basket button. Currently i manually click the button to run the code Can anyone add a auto click the button after the page loads. I am a total dumb in coding. A fully ready code is required. Please help.
<!-- The basket will be linked to this element's onClick //-->
<button id="custom-button" autofocus >Buy the basket</button>
<!-- Include the plugin //-->
<script src="https://kite.trade/publisher.js?v=3"></script>
<script>
// Only run your custom code once KiteConnect has fully initialised.
// Use KiteConnect.ready() to achieve this.
KiteConnect.ready(function() {
// Initialize a new Kite instance.
// You can initialize multiple instances if you need.
var kite = new KiteConnect("tlhzuxkhbqzcvxrw");
// Add a stock to the basket
kite.add({
"exchange": "NSE",
"tradingsymbol": "INFY",
"quantity": 5,
"transaction_type": "BUY",
"order_type": "MARKET"
});
// Register an (optional) callback.
kite.finished(function(status, request_token) {
alert("Finished. Status is " + status);
});
// Render the in-built button inside a given target
kite.renderButton("#default-button");
// OR, link the basket to any existing element you want
kite.link("#custom-button");
});
</script>