Back to all resources
jQuery
Event Handling

Select Radio on Load

By Jared Malan
This code snippet is written in JavaScript and utilizes jQuery for DOM manipulation. It checks the value of the variable radio_value and performs actions based on its value. If radio_value is equal to "button-1", it triggers a click event on the parent element of the HTML element with the ID button-1. Similarly, if radio_value is equal to "button-2", it triggers a click event on the parent element of the HTML element with the ID button-2. This code is typically used in scenarios where you need to simulate user interactions based on certain conditions.