Unable to set radio as checked and enclosing label as active using jQuery -


i have 1 set of radio buttons (greatly simplified original html):

<form action="javascript:;" id="signup-form">     <div id="first">         <label class="custom-radio">             <input type="radio" name="delivery-mode" value="normal">         </label>         <label class="custom-radio">             <input type="radio" name="delivery-mode" value="scheduled">         </label>     </div> </form> 

when click on radio button in first set want corresponding radio button in second set checked.

<div id="second">     <label class="custom-radio">         <input type="radio" name="delivery-mode" value="normal">     </label>     <label class="custom-radio">         <input type="radio" name="delivery-mode" value="scheduled">     </label> </div> 

i attempt using jquery function:

$('#first').on('click', '.custom-radio', function() {     var selector;     if ($this.find('[value="scheduled"]').is(':checked')) {         selector = '[value="scheduled"]';     } else {         selector = '[value="normal"]';     }     var radio = $('#second').find(selector);     var cradio = radio.parent();     cradio.click();     cradio.addclass('active');     radio.prop('checked', true); });  $('#second').on('click', '.custom-radio', function() {     //console.log('hello');     var value = $(this).find('input').val();     console.log(value); }); 

i know finding correctly corresponding radio label in second set of radio buttons because click works correctly.

however adding 'active' class label not work nor setting checked attribute of radio button. able other things modify value of radio button or change class else other 'active'. reason can't these 2 things indicate radio button checked.

what doing wrong? please help. :-)

i realized not able boil down problem seeing reproducible stackoverflow community. therefore going mark question resolved. if can reproduce in simple manner i'll repost.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -