0
Return an array with each green value on the page load (show in 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>
Illustrious, good afternoon! I got no effect on the project. It can be more specific.
– Márcio Christian Da Silva
I replaced your script at the end of the page and put inside this new function
– João Victor Souza
It creates an array of values and starts going through the span’s on the page, so it generates the code ('cxxx-xxbx-xaxx') and puts it in html and at the same time adds the event to the button
– João Victor Souza
Do you get any error on the console? I ran here with the page you posted and it worked perfectly.
– João Victor Souza
The screen is static, it is not returning an array with each green value in the page load (show in the console). When the button is clicked, return the value immediately above the button.
– Márcio Christian Da Silva
Running here on the site works normally?
– João Victor Souza
Here on the site works!
– Márcio Christian Da Silva
Executes the code I posted on the console in the browser, see if it has effect, for some reason it seems that the function is not calling itself in the page loading
– João Victor Souza