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,
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('times');//获取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!