I am currently working on a dynamic pickup date form that utilizes radio buttons. My goal is to change the style of the selected value when a user clicks on it. Below is the code I have tried, but it has not been successful:
foreach ($period as $day){
echo '<label class="pickup-date" id="pickupdate"><input type="radio" value="'.$day->format('M-d-Y').'" name="pickup_date">'.$day->format('M') . ' <span>' .$day->format('d') . '</span> '. $day->format('D') .'<br/></label>';
}
Css
.pickup-date-tab label.checked{
background: #6d1f89 !important;
color: #fff; }
jquery
$('#pickupdate').on('click',function(){
$('#pickupdate').removeClass('checked');
$(this).addClass('checked');
});
The issue I'm having is that this code only works for the first button.