DIV点击,重新运行动画只需点击三下即可点击一下 [英] DIV click, re run the animation takes three clicks insterd of one click

查看:82
本文介绍了DIV点击,重新运行动画只需点击三下即可点击一下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从我的网站侧面写了一个滑块,它基于一个Clickble DIV。并且它有一个下面给出的javascript。问题是当我第一次按div时。它会很好地完成这项工作,好吧现在我打开它,然后关闭它。之后我点击返回打开。

#good news它会打开

#bad新闻是否需要三次点击才能运行剩余的尝试。



$如果你能解决这个问题,我真的很喜欢它。



我尝试了什么:



function left_nav_slider_button(){

var status = true;

var open_close_swich = document.getElementById('open_close_swich')。addEventListener('click',try_it,true)

open_close_swich.addEventListener( click,function(e){

e.preventDefault();

if(status === true){

$(这个).parent()。toggleClass('slidein_left');

status = false;

console.log('1st');

}

else

{

$(this).parent()。toggleClass('slideout_left');

status = true;

console.log(第二个');

}

});

}

}

解决方案

如果你能解决这个问题,我真的很喜欢它。



我尝试了什么: < br $>


函数left_nav_slider_button(){

var status = true;

var open_close_swich = document.getElementById('open_close_swich ')。addEventListener('click',try_it,true)

open_close_swich.addEventListener(click,function(e){

e.preventDefault();

if(status === true){


(this).parent()。toggleClass('slidein_left');

status = false;

console.log('1st');

}

else

{


(this).parent()。toggleClass('slideout_left');

status = true;

console.log('2nd');

}

});

}

}

I have written a slider come off from the side of my website and it's based on one clickble DIV. And it has a javascript given below.The issue is that when i press the div for the first time. it will do the job nicely, OK Now i opend it,and then close it.after that i click back to open back.
#good news is it will open
#bad news is it needs three clicks to run for the rest of the attempts.

$if you can solve this problem, i really appriciate it.

What I have tried:

function left_nav_slider_button(){
var status=true;
var open_close_swich=document.getElementById('open_close_swich').addEventListener('click',try_it,true)
open_close_swich.addEventListener("click",function(e){
e.preventDefault();
if (status===true){
$(this).parent().toggleClass('slidein_left');
status=false;
console.log('1st');
}
else
{
$(this).parent().toggleClass('slideout_left');
status=true;
console.log('2nd');
}
});
}
}

解决方案

if you can solve this problem, i really appriciate it.

What I have tried:

function left_nav_slider_button(){
var status=true;
var open_close_swich=document.getElementById('open_close_swich').addEventListener('click',try_it,true)
open_close_swich.addEventListener("click",function(e){
e.preventDefault();
if (status===true){


(this).parent().toggleClass('slidein_left');
status=false;
console.log('1st');
}
else
{


(this).parent().toggleClass('slideout_left');
status=true;
console.log('2nd');
}
});
}
}


这篇关于DIV点击,重新运行动画只需点击三下即可点击一下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆