Sorry for the too simple question, I almost don’t understand jQuery, but the work needs to be done.

Task: - If a radio button is selected - show a hidden image and text, do not hide until it switches to another radio button. - According to the hover on the text of the radio button - show only the picture.

With my code, only the second function with hover works. Those. when you hover on the radio button, the picture appears, but when you select - no.

How to fix it?

<script> $('.img2, .img3, .img4, .img5, .img6, .img7').hide(); $('#pic1').css('opacity','1'); $('.text').hide(); $(document).ready(function() { $('input[type="radio"]').click(function() { if($(this).attr('id') == 'item1') { $('#pic5, #text1').show(); } else { $('.img5, #text1').hide(); } }); $("#desc1").mouseenter(function(){ $('#pic5').show(); }); $("#desc1").mouseleave(function(){ $('#pic5').hide(); }); }); </script> 

  • work out both, but when you remove the mouse after the click, the picture disappears again. - teran
  • Can you tell me what needs to be corrected so that the functions work in parallel? When a hover picture appears, disappears, when you select it appears and remains? - Anton Kuzmich
  • And so in the show and hide code, the images work independently. Make a hover additional check on the state of the radio. If pressed, then do not hide when abducted, if not pressed, then hide. In the beginning, it is better that all that is done is jQuery to push into the function $ (document) .ready (). Well, to better understand the problems put an example on any service, like jsfiddle.net or codepen.io. I am sure that you will receive advice or decision faster. - Anton K.

0