onerkript onerkript - 2 years ago 89
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?

Answer Source

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

  $(this).next('').find('input[type="radio"]').prop('checked', true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download