The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Selecting radio button when table-row is clicked Reply To: Selecting radio button when table-row is clicked


Aside from the selected class needed on the <tr> I’ve managed to get this ‘working’ using the following script:

$('.product-options tr').click(function() {
    $(this).find('td input[type=radio]').prop('checked', true);
   // $(this).find('td .radio span').addClass('checked', true);

One side issue I have is I use uniform.js to style my selects, radio and checkboxes. This wraps radio buttons like so (so they can be styled):

<div class="radio">
    <span class="checked">
        <input type="radio" name="product_variation" checked="checked" />

<div class="radio">
        <input type="radio" name="product_variation" />

Clicked directly on the radio button changes the checked class accordingly on the radio div/span. But if you click a table row, it does not. How could I go about ensuring the checked class (styling) on .radio span matches that of the input?