I’m doing an adaptive on the wheelchair site, in the product card there is an opportunity to choose the color of the product, it happens, but the record of the most chosen color disappeared after Choose a color enter image description here , before the product card adaptation procedure, this record was displayed when choosing a color. How to fix this mistake, help, my head is turning I can not find the script that is responsible for it. Thank.

UPD: I clarify my question: the choice of color works, but the recording of the selected color is not displayed (as in the screenshot), js I have not changed, only the markup and styles;

    1 answer 1

    On the script page

    $('input').on('change', function() { $('input.action').removeClass('action'); $(this).addClass('action'); $(this).find('input[type=radio]').checked = true; }); 

    You are trying to find the input with the radio type inside the input element and set the checked attribute. Correct.

    The event does not need to put all input elements, take in the context of the choice of color

     $('.item_info .option input[type="radio"]') 
    • one
      Regarding debugging, if you don’t know where to look: in Chrome, press F12, select the element from which we assume the attribute changes when pressed, right-click, select Break on... -> Attributes Modifications and perform the action that changes the attribute. Next we work with debugging after the breakpoint has been activated. - Invision
    • that is, $ (this) .find ('input [type = radio]'). checked = true; change to $ ('. item_info .option input [type = "radio"]'). checked = true; - sagan
    • one
      not. $(this).prop('checked', true) enough. You can do without JS at all, wrap the radio button in the label element and in the css by state: checked hang the desired style - Invision
    • Thank you for such useful advice and comment - sagan
    • Unfortunately, replacing with $ (this) .prop ('checked', true) did not give any result - sagan