First, give your radio books some class names, so you can use them with javascript more easily.
<%= radio_button 'relat', 'atu', 'yes', {:class => "relat__atu relat__atu_yes"} %> ATU
<%= radio_button 'relat', 'atu', 'no', {:class => "relat__atu relat__atu_no"} %> No ATU
Now you attach the event handler to the change event. And switch the display of your other item, depending on whether the Yes button is turned on.
$(".relat__atu").on("change", function(){
$("#esatu").toggle($(this).hasClass("relat__atu_yes"));
});
source
share