2013-03-04 193 views
1

我一直在尝试不同的方法,使一个div添加自己当切换DIV是可见的,删除时不。但其他的不读,不管我怎么说,else语句永远不会被读取。的jQuery如果else语句不工作

这就是我现在

if ($('#toboggan-login').css('display') == 'none'){ 
    $("#art-main").append('<div class="outer-login"></div>'); 
} else{ 
    $("#art-main").find(".outer-login").removeClass(); 
} 

有我也有尝试:可见光和计数器:隐藏,但不管它如何阅读作品,如果我不能得到语句的其他部分我不能得到的预期的效果。

这是Drupal的6网站IM在

+0

是什么触发这个? – 2013-03-04 22:40:02

+0

你什么时候运行这个,只有在页面加载? – adeneo 2013-03-04 22:40:13

+0

我认为你需要的是一个开始的工作示例,否则可能不是问题。希望这有助于;)http://codepen.io/anon/pen/qomAI – Shanimal 2013-03-04 23:29:37

回答

0

你可能需要将这个代码以“#雪橇登录”的触发事件连接工作。喜欢的东西:

$('#toboggan-login').toggle('slow', function() { 
    if ($(this).css('display') == 'none'){ 
    $("#art-main").append('<div class="outer-login"></div>'); 
    } else{ 
    $("#art-main").find(".outer-login").remove(); 
    } 
}); 
+0

这与一些摆弄工作。非常感谢。 – PH83 2013-03-05 15:34:29