onerkript onerkript - 1 year ago 53
jQuery Question

Check input radio on image click

Here's my HTML:

<img src="img.jpg" class="img-ms-form">
<div class="radio">
<label class="radio"><input type="radio" name="optradio-1" required>Option 1</label>

I'm trying to check the radio button if the image is clicked. Here's what I've tried:

$(this).next('input[type=radio]').prop('checked', true);

But this doesn't seem to work, what am I doing wrong?


Use .next() and .find() as shown :-

  $(this).next('').find('input[type="radio"]').prop('checked', true);