Skip to content
Advertisement

Using jquery connections but it isn’t connecting div’s together?

I am trying to create this page where I have different div and buttons that are scattered on the page and connecting them using jquery connections by musclesoft

I have tried this code but it seems that the connection isn’t happening at all, I can’t figure out what the issue is?

button {
  min-width: 120px;
  height: 120px;
  background: #f56c29;
  border-radius: 60px;
}

connection {
  border: 30px solid #b51c29;
  border-radius: 50px;
}


button.about {
  position: absolute;
  transition: .5s ease;
  top: 50%;
  left: 50%;
}
<!DOCTYPE html>
<html lang="en" >
<!-- Include jQuery and the Connections plugin -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="jquery.connections.js"></script>
<!-- Connect your elements like in this example -->
<script>
  jQuery(document).ready(function() {
    $('div').connections();
  });
</script>
<head>
  <meta charset="UTF-8">
  <title>CodePen - A Pen by rasbsal</title>
  <link rel="stylesheet" href="./style.css">

</head>
<body>
  <div>
      <button>
          Text
      </button>
  </div>
  <div>
      <button class="about">
          About
      </button>
  </div>
</body>
</html>

Advertisement

Answer

The connections are not visible because there’s actually no space between the div elements (go to Inspect Element in Dev Tools and see for yourself highlighting the two DIV elements).
Use button as your connecting selector

jQuery(($) => {
  $('button').connections();
});
button {
  min-width: 120px;
  height: 120px;
  background: #f56c29;
  border-radius: 60px;
}

connection {
  border: 30px solid #b51c29;
  border-radius: 50px;
}

button.about {
  position: absolute;
  transition: .5s ease;
  top: 50%;
  left: 50%;
}
<div>
  <button>Text</button>
</div>
<div>
  <button class="about">About</button>
</div>


<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/musclesoft/jquery-connections@1.0.1/jquery.connections.js"></script>
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement