jQuery_Studio loops

In this example below you will see how to do a jQuery_Studio loops with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by mrjohnson, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright mrjohnson ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>jQuery_Studio loops</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div class="wrap">
  <ul class="attach">
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
  </ul>
</div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/mrjohnson/jquery_studio-loops-GxdLKV */
body{
  margin: 0;
  padding: 0;
}
.wrap{
  width: 500px;
  height: 200px;
  margin: 0 auto;
  position: relative;
  background:#112233;
  cursor: pointer;
}
.attach{
  list-style:none;
  position: absolute;
  bottom: 0;
}
.attach li{
  width: 20px;
  height: 20px;
  background:#666;
  display: inline-block;
  border-radius:10px;
  margin-right:8px;
  transition-timing-function: linear;
  -moz-transition-timing-function: linear;
  -webkit-transition-timing-function: linear;
  -o-transition-timing-function: linear;
}

/*Downloaded from https://www.codeseek.co/mrjohnson/jquery_studio-loops-GxdLKV */
$(".wrap").click(function() {
  $(this).toggleClass("active");
  if ($(this).hasClass("active")) {
    clearInterval(stopRun);
  } else {
    stopRun = setInterval(autoRun, 200);
  }

});
function autoRun() {
  $(".attach li").each(function() {
    randomNum();
    $(this).css({ height: newHeight, "transition-duration": ".2s" });
    $(this).on("transitionend", function(event) {
      $(this).css({ height: "20px" });
    });
  });
}
function randomNum() {
  newHeight = Math.floor(Math.random() * (80 - 0) + 20);
}

Comments