Return an array with each green value on page load (show on console). When the button is clicked, return the value immediately above the button.
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Teste 002</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.min.js"integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=" crossorigin="anonymous"></script>
<script>
(function (win, doc) {
var f = doc.getElementsByTagName("script")[0];
var j = doc.createElement("script");
j.async = true;
j.src = './tagueamento.js';
f.parentNode.insertBefore(j, f);
})(window, document);
</script>
</head>
<body>
<h1>
Retorne um array com cada valor verde no carregamento da página (mostrar no console). Quando o botão for clicado,
retorne o valor imediatamente acima do botão.
</h1>
<style>
#valores span {
background: green;
}
span{
color: white;
}
#valores span, #botoes a {
width: 125px;
margin: 1em;
text-align: center;
display: block;
float: left;
border: 1px solid black;
}
#botoes {
float: left;
}
</style>
<div id="valores">
<span></span><span></span><span></span><span></span><span></span>
</div>
<div id="botoes">
<a>1</a>
<a>2</a>
<a>3</a>
<a>4</a>
<a>5</a>
</div>
<script>
$('#valores').find('span').each(function () {
$(this).text('cxxx-xxbx-xaxx'.replace(/x/g, function () {
return Math.floor(Math.random() * 10).toString(10);
}))
})
</script>
</body>
</html>