I have in the HTML document a certain element that has ordinal numbers 0-9.
I'm trying to use the reverse();
method to invert the order of numbers in my element. The logic should be:
1- capturing the output of the element id
, which is in a tag <span>
2- make the inversion of 9 - 0
3 - put it back in the element.
Attempt 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>