JavaScript and the DOM

0. The first Javascript code:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function displayDate(){
    
    
	document.getElementById("c").innerHTML=Date();
}
</script>
</head>
<body>

<h3>第一个 JavaScript 代码</h3>
<p id="c">段落</p>

<button type="button" onclick="displayDate()">显示日期</button>

</body>
</html>

1.DOM:Document Object Model

Purpose
(1) Get document information
(2) Modify document information
(3) Get document element information

3. According to the DOM, javascript can perform the following operations:

JavaScript can change all HTML elements in the page
JavaScript can change all HTML attributes in the page
JavaScript can change all CSS styles in the page
JavaScript can react to all events in the page
and operate on forms and nodes

Guess you like

Origin blog.csdn.net/m0_59416550/article/details/127400515