I have a problem, I have a word that when you load the page each letter has a different color use
<style> #word span:nth-child(9n + 1) { color:#ff2222; } #word span:nth-child(9n + 2) { color:#22aa22; } #word span:nth-child(9n + 3) { color:#ffaa22; } #word span:nth-child(9n + 4) { color:#aa00aa; } #word span:nth-child(9n + 5) { color:#00aaa0; } #word span:nth-child(9n + 6) { color:#ff06d5; } #word span:nth-child(9n + 7) { color:#9f5522; } #word span:nth-child(9n + 8) { color:#a10c97; } #word span:nth-child(9n + 9) { color:#22ffcf; } </style>
$(function(){ $('#word').html( $('#word').text().replace(/(\w)/g,'<span>$1</span>') ); })
but when I click on a button to change the word, the span generated by the script disappears, but I need it to remain so to speak.
<div class="centro">
<h1 id="word">
Click On Button
</h1>
</div>
<div>
<form method="post" class="centro">
<input type="button" name="catg" value="New Word" class="centro w" onclick="boton()">
</form>
</div>
</div>
<script type="text/javascript"> var boton = function() { fetch('sqla.php') .then(function(response) { return response.text(); }) .then(function(body) { document.querySelector('#word').innerHTML = body; }); }; document.addEventListener('click', function() { boton(); }); </script>