我需要在条件语句中运行一个函数,根据3个元素是否有类来确定。
简而言之,如果(elm1, elm2, elm3)都具有“include”类,则为true。但是所有3个元素必须具有该类,如果只有2个或1个具有该类,则不能为true。
<div class="elm1" class="include"></div>
<div class="elm2" class="include"></div>
<div class="elm3" class="include"></div>
jQuery('#search-submit').click(function() {
if (#elm1, #elm2, #elm3).hasClass('include'){
/* return true */
} else {
/* return false */
}
}
毋庸置疑,这并不起作用。
<div>
元素都具有“include”类时执行“true section”?还是你只需要至少1个?(如果你需要3个,我非常确定你接受的答案是错误的,但请务必验证) - Amit