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');
}
});
}
}