Hwe*_*nde 2 html javascript jquery
我一直在使用以下代码来检查div是否可见:
if ($("#monday").is(':visible')) {
document.getElementById('scheduleitem1').style.width = 540;
$("#scheduleitem1").show();
}
Run Code Online (Sandbox Code Playgroud)
该代码运行良好.但是,我想检查一次是否可以看到多个div中的一个.
我尝试过以下不起作用的代码:
if ($("#monday" || "#tuesday").is(':visible')) {
document.getElementById('scheduleitem1').style.width = 540;
$("#scheduleitem1").show();
}
Run Code Online (Sandbox Code Playgroud)
和
if ($("#monday", "#tuesday").is(':visible')) {
document.getElementById('scheduleitem1').style.width = 540;
$("#scheduleitem1").show();
}
Run Code Online (Sandbox Code Playgroud)
那么如果我想检查一个多个div中的一个是否同时可见,我该怎么办?
试试这个 :
$("#monday,#tuesday").is(':visible')
Run Code Online (Sandbox Code Playgroud)
http://api.jquery.com/is/:"...如果这些元素中至少有一个与给定的参数匹配,则返回true".