Bilal Adlial Awan Bilal Adlial Awan - 3 months ago 12
HTML Question

Click a radio button automatically on page load

Here is my code

jQuery('#choice_1_10_3_1').attr('checked','checked');


I want to check this radio button when the page load. I could not found error in console but my code is not working.
It is essential for me to do. Any help will be appreciated. Thanks.

Answer

The code will be run after the page is fully loaded.

Try this :

$(window).load(function() {
    $('#choice_1_10_3_1').attr('checked', true);
});