jQuery After page loaded, check if radio button selected

Homer_J picture Homer_J · Sep 7, 2013 · Viewed 34.2k times · Source

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?

Answer

Daniele picture Daniele · Sep 7, 2013

Try with:

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