0

Working example: https://codepen.io/stevland/pen/arOEEQ.

I am using jQuery to change the opacity of a corresponding table based on which radio button is toggled on/off.

$('input:radio').click(function() {
    $("input:radio").each(function() {
        $(this).closest("table").toggleClass("highlight", $(this).is(":checked"));
    });
});

It works well except for one caveat: when visiting the page one has to click a radio button to initiate the function.

I'd like to expand the code to work as soon as the page is loaded, based on which radio button is already checked:

<input type="radio" checked />
stevland
  • 119
  • 1
  • 8

0 Answers0