Home >Web Front-end >HTML Tutorial >Example analysis of using output tag to mark JavaScript return value
Sometimes some data information on the page is filled in after calculation through js. In the past, developers would often treat the 45a2772a6b6107b401db3c9b82c049c2
element as a placeholder and specify an ID attribute so that the JavaScript code could Find it and fill in the data. In
HTML5, it is recommended to use be6d67dae90cc1ad6469079e163d0939
as a placeholder to make the semantics clearer. The actual usage is the same as the previous 45a2772a6b6107b401db3c9b82c049c2
of.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>随机数生成</title> <script> function run(){ var resultElement = document.getElementById("result"); resultElement.value = Math.random(); } </script> </head> <body> <p>随机数:<output id="result"></output></p> <input type="button" value="生成" onclick="run()"> </body> </html>
The above is the detailed content of Example analysis of using output tag to mark JavaScript return value. For more information, please follow other related articles on the PHP Chinese website!