html
<select name="register-month" id="register-month"> <option value="00">Month</option> <option value="01">January</option> <option value="02">February</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <option value="06">June</option> <option value="07">July</option> <option value="08">August</option> <option value="09">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select>
JQuery
function checkbirthday() { var register_month_value = $("#register-month").val(); //month check if (register_month_value === "") { $("#register-month option[value='00']").remove(); $('#register-month').css('border-color', 'red'); } else { $('#register-month').css('border-color', '#dfe0e6'); } return; } $(document).ready(function() { $("#register-month").keyup(checkbirthday); });
My intention was simple, at first I wanted to turn off the βMonthβ, as soon as they click on the selection, the second, if the choice is empty, change the css border to red.
But I tried many ways, still no luck, what is wrong here?
source share