.circle {
width: 10px; /* Diameter of the circle */
height: 10px; /* Diameter of the circle */
border-radius: 50%; /* This creates the round shape */
background-color: blue; /* Background color of the circle */
margin: 2px;
display: block; /* Ensure the circle fills the anchor */
}
a.circle-link {
float: left; /* Align the links as the circles were */
}
function createCircles(numberOfCircles) {
const container = document.getElementById(‘circles-container’);
for (let i = 0; i < numberOfCircles; i++) {
// Create an anchor element
const link = document.createElement('a');
// Set the href attribute to navigate to Google
link.href = '
https://instagram.com';
// Optional: Open in a new tab
link.target = '_blank';
link.className = 'circle-link'; // Add class for styling
// Create the circle div as before
const circle = document.createElement('div');
circle.className = 'circle';
// Append the circle to the anchor element
link.appendChild(circle);
// Append the anchor element to the container
container.appendChild(link);
}
}
createCircles(5000); // Call the function with 5000 or any number you wish
<!DOCTYPE html>
<html>
<head>
<style>
.circle {
width: 10px; /* Diameter of the circle */
height: 10px; /* Diameter of the circle */
border-radius: 50%; /* This creates the round shape */
background-color: blue; /* Background color of the circle */
margin: 2px;
display: block; /* Ensure the circle fills the anchor */
}
a.circle-link {
float: left; /* Align the links as the circles were */
}
</style>
</head>
<body>
<div id="circles-container"></div> <!-- Container for the circles -->
<script>
function createCircles(numberOfCircles) {
const container = document.getElementById('circles-container');
for (let i = 0; i < numberOfCircles; i++) {
// Create an anchor element
const link = document.createElement('a');
// Set the href attribute to navigate to Google
link.href = 'https://www.google.com';
// Optional: Open in a new tab
link.target = '_blank';
link.className = 'circle-link'; // Add class for styling
// Create the circle div as before
const circle = document.createElement('div');
circle.className = 'circle';
// Append the circle to the anchor element
link.appendChild(circle);
// Append the anchor element to the container
container.appendChild(link);
}
}
createCircles(5000); // Call the function with 5000 or any number you wish
</script>
</body>
</html>
Leave a Reply