Home >Web Front-end >HTML Tutorial >What is the innerHTML property? Usage of innerHTML attribute

What is the innerHTML property? Usage of innerHTML attribute

不言
不言Original
2018-08-06 16:43:3510383browse

What is the use of the innerHTML attribute? This article introduces to you what is the innerHTML attribute? The usage of i and nnerHTML attributes has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

innerHTML attribute

The inner attribute can return or set the content in the element

For example, 25edfb22a4f469ecb59f1190150159c6aaaaabed06894275b65c1ab86501b08a632eb

Access li.innerHTML to get the content aaaaa

You can also assign content to the tag

Example: Get the current time (refreshed every second)

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <div id="times"></div>
    <li>aaaaa</li>
</body>
    <script type="text/javascript">
        function gettimes(){ 
        var date1 = new Date();//创建时间对象
        var date2 = date1.toLocaleString();//使用格式为年月日时分秒
        var div1 = document.getElementById(&#39;times&#39;);//获取div格子
        div1.innerHTML = date2;//向html中写内容
 
        }
 
        setInterval("gettimes();",1000);//"js代码",时间
    </script>
</html>

Recommended related articles:

What is responsive layout? Implementation of html responsive layout

#What are the common types of html layout? Analysis of the three layout characteristics of html

The above is the detailed content of What is the innerHTML property? Usage of innerHTML attribute. 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