<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="divPai">
<div id="bannerA" class="banner">
<a href="link1"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/225865593/rmu3bewcv3pqkzx32hjk-qe5uzhcwvt.jpg" alt="Imagem 1"></a>
<a href="link2"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/217352435/rfl14_off_pk_1-v2ofz4r0h3.jpg" alt="Imagem 2"></a>
<a href="link3"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/77172972/45c63850c8.jpg" alt="Imagem 3"></a>
</div>
<hr>
<div id="bannerB" class="banner">
<a href="link4"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/225865593/rmu3bewcv3pqkzx32hjk-qe5uzhcwvt.jpg" alt="Imagem 4"></a>
<a href="link5"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/217352435/rfl14_off_pk_1-v2ofz4r0h3.jpg" alt="Imagem 5"></a>
<a href="link6"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/77172972/45c63850c8.jpg" alt="Imagem 6"></a>
</div>
<hr>
<div id="bannerC" class="banner">
<a href="link7"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/225865593/rmu3bewcv3pqkzx32hjk-qe5uzhcwvt.jpg" alt="Imagem 7"></a>
<a href="link8"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/217352435/rfl14_off_pk_1-v2ofz4r0h3.jpg" alt="Imagem 8"></a>
<a href="link9"><img src="https://cdn.awsli.com.br/2500x2500/1737/1737952/produto/77172972/45c63850c8.jpg" alt="Imagem 9"></a>
</div>
</div>
</body>
</html>
/*document.addEventListener("DOMContentLoaded", function() {
// var banner = document.getElementById("divPai");
// var images = banner.querySelectorAll("img");
var images = document.querySelectorAll("#bannerA img");
// Função para exibir uma imagem aleatória
function showRandomImage() {
// Escolhe aleatoriamente um índice de imagem
var randomIndex = Math.floor(Math.random() * images.length);
// Define todas as imagens como ocultas
images.forEach(function(img) {
img.style.display = "none";
});
// Exibe a imagem aleatória
images[randomIndex].style.display = "block";
// images[randomIndex].style.className()
}
// Chama a função inicialmente e define um intervalo para exibir novas imagens a cada 3 segundos
showRandomImage();
setInterval(showRandomImage, 3000);
// makeSliderKind('.bannerA', 1000);
// makeSliderKind('.bannerB', 2000);
// makeSliderKind('.bannerC', 3000);
});
*/
function makeSliderKind(containerClass, intervalTime){
var images = document.querySelectorAll(containerClass+" img");
// Função para exibir uma imagem aleatória
const showRandomImage = () => {
// Escolhe aleatoriamente um índice de imagem
var randomIndex = Math.floor(Math.random() * images.length);
// Define todas as imagens como ocultas
images.forEach(function(img) {
img.style.display = "none";
});
// Exibe a imagem aleatória
images[randomIndex].style.display = "block";
};
// Chama a função inicialmente e define um intervalo para exibir novas imagens a cada 3 segundos
showRandomImage();
setInterval(showRandomImage, intervalTime);
}
makeSliderKind('#bannerA', 2000);
makeSliderKind('#bannerB', 10000);
makeSliderKind('#bannerC', 3000);
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |