Domas Domas - 6 months ago 122x
Javascript Question

Check if selected dropdown value is empty using jQuery

Here is the dropdown in question:

<select name="data" class="autotime" id="EventStartTimeMin">
<option value=""></option>
<option value="00">00</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>

What I want to do is check if the current value is empty:

if ($("EventStartTimeMin").val() === "") {
// ...

But it does not work, even though the value is empty. Any help is much appreciated.


You forgot the # on the id selector:

if ($("#EventStartTimeMin").val() === "") {
    // ...