【发布时间】:2014-03-24 03:27:14
【问题描述】:
我正在运行一个 jQuery 脚本并且它工作正常,但是我有一些切换功能,当您单击它时可以将 div 滑入和滑出。第一次您必须双击它才能使其工作,我很想删除它。有谁知道它为什么会发生?这就是我的意思 http://www.gregtaylordesignstudio.com/great-Lakes-Project/actions.html
这是脚本
$(document).ready(function(){
$(".inline").colorbox({inline:true, width:"50%"});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
var slideout = $('#actionsBlurb');
$('#dots').hide();
$('#mapBack').delay(1000).animate({top:"45px"},800).fadeOut(400);
$('#mapBackTop').delay(1000).fadeOut(1000);
slideout.delay(4000).animate({ right: 175, }, { duration: 1000, easing: 'easeOutExpo'});
var open = true;
$(".close").click(function () {
if(open === false) {
open = true;
slideout.animate({ top: '-170px'}, { queue: false, duration: 500 });$('#dots').fadeIn(2000);
} else if(open === true) {
open = false;
slideout.animate({ top: 0}, { queue: false, duration: 500});$('#dots').fadeOut(1000);
}
});
})
;
【问题讨论】:
-
您能否请在发布之前清理代码的缩进。仅仅因为你不在乎你的代码是什么样子并不意味着其他人想看一团糟。
-
我不确定,但我猜问题是你开始
var open = true,而实际上 div 开始关闭。 -
我会使用 console.log 或警报消息来确定是否没有收到事件,或者是否存在逻辑问题。
-
您的示例 URL 也是 404'd
-
谢谢饼干怪兽。你是对的。
标签: javascript jquery