Checked radio button on select option change

542 Views Asked by At

When I change the value of a select option, a corresponding radio button should be clicked.

$(document).ready(function(){
    $('#colorselector').on('change', function() {

        if ( this.value == 'red')
        {
            $('input[name="purchase[product_id]"][value="000000"][type="radio"]').click();
        }
    });
});
1

There are 1 best solutions below

0
AudioBubble On BEST ANSWER

use

.prop('checked',true);

instead of

.click();

if what you wanted is to make the radio "checked"