If you want to store some data in a tage you could use the data- tag.
try it:
code:
1
code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<!DOCTYPE html> <html> <body> <p id="test" data-old="1">1</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("test").setAttribute("data-old",document.getElementById("test").innerHTML); document.getElementById("test").innerHTML = 2*document.getElementById("test").innerHTML; } </script> </body> </html> |