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

Example analysis of using output tag to mark JavaScript return value

黄舟
Release: 2017-07-03 10:35:48
Original
1664 people have browsed it


Sometimes some data information on the page is filled in after calculation through js. In the past, developers would often treat the <span> 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 <output> as a placeholder to make the semantics clearer. The actual usage is the same as the previous <span> 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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template