title: jQuery on/off function with one button not working?
body: <p>I want to make my button work as a lights on and off, I tried this with two seperate buttons and it worked, but as I made it into one single button it doesn't work, it gives out the alerts, but doesn't change the styles, any suggestions? I kinda mixed javascript with jquery, maybe theres some syntax problems (i followed multiple tutorials on js and jquery)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $("#lights").click(function() {
      if (ijungtas == 0) {
        ijungtas = 1;
        alert("a")
      } else {
        ijungtas = 0
        alert("b")
      }
    });
  
    if (ijungtas == 1) {
      $("#lights").click(function() {
        $(".tamsus").css({
          display: 'block',
          "background-color": "black",
          "position": "absolute",
          "color": "#fff",
          "height": "100vh",
          "width": "100%",
          "z-index": "88",
        });
      });
  
      $("#lights").click(function() {
        $(".wrapper").css({
          display: 'none'
        });
      });
  
      $("#lights").click(function() {
        $(".right_side").css({
          "z-index": "999"
        });
      });
      $("#lights").click(function() {
        $("#test").css({
          "display": "none"
        });
      });
      $("#lights").click(function() {
        $(".room_box").css({
          "opacity": "0"
        });
      });
  
      $("#lights").click(function() {
        $("#hostname").css({
          "opacity": "0"
        });
      });
    }
  
    if (ijungtas == 0) {
      $("#lights").click(function() {
        $(".wrapper").css({
          display: 'block'
        });
      });
  
      $("#lights").click(function() {
        $(".right_side").css({
          "z-index": "0"
        });
      });
  
      $("#lights").click(function() {
        $(".tamsus").css({
          "display": "none"
        })
      });
  
      $("#lights").click(function() {
        $(".right_side").removeClass("active")
      });
  
      $("#lights").click(function() {
        $(".test").css({
          display: 'flex'
        });
      });
  
      $("#lights").click(function() {
        $("#test").css({
          "display": "inherit"
        });
      });
  
      $("#lights").click(function() {
        $(".room_box").css({
          "opacity": "1"
        });
      });
  
      $("#lights").click(function() {
        $("#hostname").css({
          "opacity": "1"
        });
      });
    }
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.tamsus .active {
    display: none !important;
    background: black !important;
  }
  
  .left_container {
    z-index: 89 !important;
  }
  
  .room_box .active {
    font-size: 100px;
  }
  
  .chat .active {
    display: none !important;
    z-index: 99;
  }
  
  .test .active {
    display: none !important;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;button class="focus-time" id="lights" value="Lights on/off"&gt;Lights on/off&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>