我有以下语句,用于检查id为#Drop的任何Div是否为空,如果其中一个为空,则显示警报。然而,当前当任何div中有内容时,该语句不再起作用。
我想表达的是,如果任何一个div为空,我希望出现警报。总共有4个Div,如果其中任何一个为空,警报消息应该出现,即使例如4个中的3个具有内容,只要有一个空的div,警报就应该触发。
HTML:
我想表达的是,如果任何一个div为空,我希望出现警报。总共有4个Div,如果其中任何一个为空,警报消息应该出现,即使例如4个中的3个具有内容,只要有一个空的div,警报就应该触发。
HTML:
<div id="Drop1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<div id="Drop2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<div id="Drop3" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<div id="Drop4" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
JS:
$("#run").click(function(){
if ($("[id^='Drop']").html() === ""){
alert("empty")// ...
}
});
if ($("[id^='Drop']").is(':empty')){...}
。 - A. Wolff