我想弄清楚如何將「或」語句添加到腳本。如果.content大於245px,或者div.content在其內部的任何地方都沒有.landing-no-display,那麼請將該類.show添加到.more。如果div有高度或類存在,然後添加類
我在下面的方式無法正常工作...類.show始終得到應用。
if ($('.importantNotice .content').height() >= 245 || ($('.importantNotice .content .landing-no-display'))) {
$('.importantNotice .more').addClass("show");
}
謝謝@godblessstrawberry。我認爲.hasClass必須指定要檢查的項目。在我的情況下,我想知道類.landing-no-display是否存在於任何內部,作爲.content的後代而不指定它分配給的項目。 – Brandon
@Brandon得到了它,更新了答案 – godblessstrawberry