gpt4 book ai didi

Jquery "if this and if that"然后执行此操作

转载 作者:行者123 更新时间:2023-12-03 22:00:27 25 4
gpt4 key购买 nike

这应该很简单,但它对我不起作用。我想说:

如果它没有类“current”并且主体类不等于“home”,则执行此操作...

这是我正在尝试的(除其他外)但无济于事。只有第一个条件有效。

$(".nav1 > ul > li").mouseleave(function() {

if ( (!$(this).hasClass("current")) || (!$(body).hasClass("home")) ){
$(this).find(".nav-overlay").show();
}

});

我做错了什么?谢谢!

为了清晰起见,更新:

我只想在满足以下条件时显示“.nav-overlay”:

  1. 您不在主页上 (body class="home")和
  2. “.nav1 > ul > li”类别不等于“current”

最佳答案

尝试 $("body")&&:

   if ( (!$(this).hasClass("current")) && (!$("body").hasClass("home"))  ){
//...

或者这样,它会更短:

   if ( !$(this).is(".current") && !$("body").is(".home")  ){
//...

关于Jquery "if this and if that"然后执行此操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18216291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com