What are the output methods of html5 pages?

青灯夜游
Release: 2022-01-23 17:15:28
Original
3559 people have browsed it

The page output methods are: 1. Use the "window.alert('content');" statement to pop up a warning box; 2. Use the "element object.innerHTML="content"" statement to insert new elements into the specified element. Content; 3. Use the "docuemnt.write("content")" statement to write the new content into the HTML document.

What are the output methods of html5 pages?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

html5 page output method

  • Usewindow.alert()Pop up warning box

  • Use thedocument.write()method to write the content into the html document

  • Use the element object. innerHtml="value to be written";Write to HTML element

1. Use window.alert()

Copy after login

2. Manipulate HTML elements

If you need JavaScript to access an HTML element, you can use the document.getElementById(id) method

Please use the id attribute to identify HTML element, and innerHTml to get or insert element content:

我的第一个段落

Copy after login

Note: If document.write() is executed after the document has been loaded, it will cover the entire HTML page