how to stop the else condition from executing?
I have a condition where the else condition executes even the the if condition is true. How manually stop the else condition from executing when the true condition executes? I tried return false. In this case, break does not work.
$(document).keydown(function(e)
{
if开发者_C百科 (e.which == 38)
{
code inside works
}
else if (e.which == 40)
{
if (current_list_item >= end_of_list)
{
alert("Reached the end");
return false;
}
else
{
alert("Add more items");
}
}
});
That's impossible. The "if" condition is true.
精彩评论