Kraftinger Lp Kraftinger Lp - 4 months ago 14
Javascript Question

Javascript only hides element

I want to make social sidebar, which can be hidden when clicked on arrow.It hides by margin-left. I tried toggling classes, if statements, but it only hides it and doesn’t show after second click. This is my code now:


$(".socialArrow").click(function () {
$(".arrowLeft").toggleClass("fa-angle-left fa-angle-right");
var wrapper = document.getElementById("socialWrapper");
$(".fa-angle-left").click(function () { = ("-80px");

$(".fa-angle-right").click(function () { = ("0px");


<div class="socialContainer">
<ul id="socialWrapper">
...some links...

<span class="socialArrow">
<i class="arrowLeft fa fa-angle-left"></i>


Any idea how to fix it?

Sorry for my English , I’m not from UK/US.


It should work with toggleClass, this way:

$(".socialArrow").click(function () {

and CSS:

#socialWrapper.closed {
    margin-left: -80px;