I'm working on an order form. The client wants the following to happen:
If the customer selects 6:00am - 9:00am time frame, display that selection in RED. But if any other time frame is selected, display it in black.
I'm trying to learn jquery/javascript and have tried many things but cannot make this happen. Any help is greatly appreciated.
$("#reqDeliveryTime_1").change(function() {
$(this).css('color','red')
})
body {
font-size: 1rem;
color:black;
font-weight: 400;
line-height: 1.5;
padding: 15px;
margin-right: auto;
margin-left: auto;
max-width: 600px;
}
.boldRed{
font-weight:bold;
color:red;
}
fieldset{
padding-bottom: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<fieldset>
<legend>DELIVERY TIME</legend>
<h2>Please choose your delivery time</h2>
<p style="font-style:italic;">
NOTICE: 6:00am-9:00am DELIVERY TIME IS A RAIN AND OR SHINE ORDER ONLY. </p>
<label for="reqDeliveryTime"><strong>Requested Delivery Time:</strong> </label>
<select name="reqDeliveryTime" id="reqDeliveryTime" required data-hint="Please choose at least one">
<option id="reqDeliveryTime_0" selected value="Choose a Delivery Time" required>
Choose a delivery time
</option>
<option id="reqDeliveryTime_1" class="boldRed" value="6:00 am - 9:00 am"> 6:00 am - 9:00 am </option>
<option id="reqDeliveryTime_2" value="8:00 am - 12:00 pm"> 8:00 am - 12:00 pm </option>
<option id="reqDeliveryTime_3" value="10:00 am - 2:00 pm"> 10:00 am - 2:00 pm </option>
<option id="reqDeliveryTime_4" value="12:00 pm - 4:00 pm"> 12:00 pm - 4:00 pm </option>
<option id="reqDeliveryTime_5" value="2:00 pm - 6:00 pm"> 2:00 pm - 6:00 pm </option>
</select>
</fieldset>
</form>