jqueryonloadchecked

jQuery After page loaded, check if radio button selected


I can easily grab the value or check if a radio button is selected using the .click(function() but what I need to do if check to see if a radio button is selected and/ or grab its value after a page has loaded (i.e. some radio buttons are pre-selected on page load).

I assumed something like this might work but it doesn't:

$("input[type=radio][name=q22]:checked").val()

Any suggestions?


Solution

  • Try with:

    $(document).ready(function(){
        $("input[type=radio][name='q22']:checked").val()
    });