Home  >  Article  >  Web Front-end  >  Example analysis of using output tag to mark JavaScript return value

Example analysis of using output tag to mark JavaScript return value

黄舟
黄舟Original
2017-07-03 10:35:481600browse


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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn