Home > Web Front-end > JS Tutorial > JavaScript basic output and embedded writing tutorial_Basic knowledge

JavaScript basic output and embedded writing tutorial_Basic knowledge

WBOY
Release: 2016-05-16 15:36:02
Original
1230 people have browsed it

JavaScript does not have any printing or output functions.
In HTML, JavaScript is commonly 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