1
I have in Document HTML a certain element that has ordinal numbers from 0 to 9.
I’m trying to use the method reverse();
to reverse the order of numbers in my element. The logic should be:
1- capture the output (out) of the element id
, that is in a tag <span>
2- do the inversion of 9 - 0
3- re-insert into the widget.
Trial Code
<script>
window.onclick = function(){
var listar = document.getElementById('txt');
document.getElementById('txt').innerHTML = listar.reverse();
}
</script>
<body>
// Aqui No corpo do documento HTML
<span id='txt'>0 1 2 3 4 5 6 7 8 9</span>
</body>