M
M
mrzgt2015-10-30 00:31:13
JavaScript
mrzgt, 2015-10-30 00:31:13

How can I make the radiobutton select when I click on the image?

<div class="subtle-pattern" style="float: left; margin-left: 15px; border: 1px solid #ccc;padding-top: 0px;">
<div class="radio">
<label>
<input type="radio" name="myshab_body_background_subtle_patterns" value="<?php echo $file; ?>" class="input-subtle-pattern" style="display">
<div id="smallfoto"><img  src="../image/subtle_patterns/<?php echo $file; ?>" width="50px" height="50px" >   </div>
</label>
</div>									
</div>

There is a code that displays an image from RADIO BUTTON, the problem is that when you click on the image, the radio button does not change the status, you need to move the mouse and click, I can’t figure out how to fix it, as I understood because of this javascript
<script>

$(document).ready(function() {

var imgBig = $('#bigfoto img');
  imgSmall = $('#smallfoto img');

imgSmall.click(function(event) {
  event.preventDefault();
  if (imgBig.attr('src') != $(this).attr('src')) {
  imgBig.hide().attr('src',$(this).attr('src'));
  imgBig.load(function() {
    $(this).fadeIn(100);
  });
  }
  imgSmall.fadeTo(500,1);
  $(this).fadeTo(500,0.6);	
});


});
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question