Home > Web Front-end > JS Tutorial > body text

【JavaScript Tutorial】JavaScript Output

黄舟
Release: 2016-12-24 14:26:15
Original
932 people have browsed it

JavaScript Output

JavaScript does not have any printing or output functions.

In HTML, JavaScript is usually used to manipulate HTML elements.

Manipulate HTML elements

To access an HTML element from JavaScript, you can use the document.getElementById(id) method.


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

Example

<!DOCTYPE html>
<html>
<body>

<h1>我的第一个 Web 页面</h1>

<p id="demo">我的第一个段落</p>

<script>
document.getElementById("demo").innerHTML = "段落已修改。";
</script>

</body>
</html>
Copy after login

The above JavaScript statement (in the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template