谁能告诉我这个 if 语句有什么问题?
如果我单独使用两个主要条件中的任何一个,该语句都可以正常工作,但是当我添加中间的 && 语句 时,它会停止工作。我在网上搜索过,看不出有什么问题。
附言。我什至可以将中间的 && 更改为 || 声明,它也有效。我很混乱。
if ((containerId.id == "LineOne" && dropLoc == "dropLocation1.1") && (containerId.id == "LineTwo" && dropLoc == "dropLocation2.2"))
{
alert("finished");
cdpause();
}
原文由 TheWee Seal 发布,翻译遵循 CC BY-SA 4.0 许可协议
因为
containerId.id
不能同时是LineOne
和LineTwo
。同样,
dropLoc
不能同时有两个值。但它可以具有两个值之一,因此将
&&
替换为||
。