setting a value for radio buttons, i have this code var inputValue = jQuery(':radio');
jQuery(inputValue).on('change', function(){
if (jQuery(this).is(':checked')){
jQuery(this).val(true)
} else {
jQuery(this).val(false)
}
});
When I click a radio it gets the value but when I click the other one for option 2 to answer it keeps the same value what could i be wrong?
Please format the code you posted, by wrapping it in triple backticks. -> `
jQuery(inputValue).on('change', function(){ if (jQuery(this).is(':checked')){ jQuery(this).val(true) } else { jQuery(this).val(false) } });
Im on deadline, it doesn't matter jquery , I could do it with vanilla, te thing is Im trying to think How could I approach that
Обсуждают сегодня