Skip to content Skip to sidebar Skip to footer

One Of Multiple Tasks Operated By Button Won't Execute

I'm having problems with one of multiple tasks being executed by a button. The button executes two of three tasks (hides them upon .(click)), except the last one, a text-blinking j

Solution 1:

To hide .text2 clear the setInterval using clearInterval

$(document).ready(function() {
  $(".btn1").on('click', function() {
    $("p").hide();
    $(".text1").hide();
    $(".text2").hide(function() {
      clearInterval(x)
    });
    $('body').css("background", "black");

  });

  var element = $(".text2");
  var shown = true;
  var x = setInterval(toggle, 500);

  functiontoggle() {
    if (shown) {
      element.hide();
    } else {
      element.show();
    }
    shown = !shown;
  }


});
body {
  background-color: coral;
  color: white;
}

.text1 {
  padding-left: 15px;
  color: white;
  font-family: 'Orbitron', sans-serif;
  width: 250px;
  float: left;
  padding-top: 10px;
}

.text2 {
  color: white;
  width: 100px;
  float: right;
  padding-top: 10px;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="text1">
  PRESS BUTTONS BELOW
</div><divclass="text2">-- : --</div><buttonclass="btn1">online</button>

Post a Comment for "One Of Multiple Tasks Operated By Button Won't Execute"