function stopTimer() {
clearInterval(timer);
var isHovered = $('#theEnd').is(":hover");
if (isHovered == "True") {
return youWon();
}
else {
alert("You lost! try again!")
}
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
&#13;
不幸的是,即使我将id =&#34; theEnd&#34;
悬停在div元素上,代码也始终默认为else语句。答案 0 :(得分:0)
isHovered
已经是一个布尔值,您不需要检查它是真还是假只是这样做:
if (isHovered) {
// ...