'input time checking if empty jquery

Why this code is not working ? Even if I fill the input time is triggering alert('empty')

<label for="">New ETA:</label>
   <input type="time" class="neweta">
   <input type="button" onclick="newetasave(this)" value="save"></br>

function newetasave(t){
 var tr = $(t).closest('tr').prev()
 var neweta = $(t).prev('input').val()

 if ($(neweta).val("")) {
   alert('empty')

 }else {
   alert('not empty')
// $(tr).find('.eta').text(neweta)
 }
}


Solution 1:[1]

You can use just Javascript without passing by Jquery if you want

Try This

<label for="">New ETA:</label>
<input type="time" class="neweta">
<input type="button" onclick="newetasave()" value="save"></br>

 function newetasave(){
        var time=document.getElementsByClassName("neweta");
        console.log(time[0].value);
         if (time[0].value=="") {
                alert('empty')                  
            }else 
            {
                alert('not empty')
            }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tantaoui zakaria