My if never falls on the else

-5

I need to lower the volume of <audio> by clicking on the down arrow, but if is not working, it never enters else . Why?

Code:

$(document).keyup(function(e) {
    if (e.keyCode == 40) { 

if ($("#nome").get(0).volume = 0.1)
{
    $("#nome").prop('muted', true);
}
else if ($("#nome").get(0).volume = 0.4)
{
    $("#nome").prop("volume", 0.1);
}

     }
});
    
asked by anonymous 14.04.2014 / 04:52

1 answer

6

You are using = instead of == (an assignment instead of comparison):

if ($("#nome").get(0).volume == 0.1)
{
    $("#nome").prop('muted', true);
}
else if ($("#nome").get(0).volume == 0.4)
{
    $("#nome").prop("volume", 0.1);
}
    
14.04.2014 / 05:02