Autoselect Radio Button on pageload

Viewed 27

I can't seem to wrap my head around how to automatically select a radio button 2-3 seconds after you visit the page

Website: https://livishparis.com/products/pheromone-balm-buy-one-get-two

There I want that the "buy 2 get 4" button is pressed a few seconds after the page is visited. How can I do this? Thank you <3

2 Answers

add a new script:

<script src="auto_check.js">

in the script:

setTimeout(function() {
    document.getElementById('radio-1').click();
    document.getElementById('buy-two-get-four').click();
}, 2000) // 1000 is one second

You can do with JS as shown below

document.addEventListener("DOMContentLoaded", function() {
  document.getElementById("your_radio_button_id_goes_here").checked = true;
});

Related