May 29, 2021 Article blog
2. JavaScript: Change HTML content
3. JavaScript: Change the HTML style
The importance of JavaScript speaks for itself, and how to learn JavaScript quickly is important.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>w3cschool(编程狮)</title>
</head>
<body>
<h1>我的第一个 JavaScript</h1>
<p>
JavaScript 能够对事件作出反应。比如对按钮的点击:
</p>
<button type="button" onclick="alert('欢迎!')">点我!</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>w3cschool(编程狮)</title>
</head>
<body>
<h1>我的第一个 JavaScript</h1>
<p>
JavaScript 能够对事件作出反应。比如对按钮的点击:
</p>
<button type="button" onclick="alert('欢迎!')">点我!</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>w3cschool(编程狮)</title>
</head>
<body>
<h1>我的第一段 JavaScript</h1>
<p id="demo">
JavaScript 能改变 HTML 元素的样式。
</p>
<script>
function myFunction()
{
x=document.getElementById("demo") // 找到元素
x.style.color="#ff0000"; // 改变样式
}
</script>
<button type="button" onclick="myFunction()">点击这里</button>
</body>
</html>
JavaScript is sensitive to case, so be aware that case toggles are accurate, such as: getElementById and getElementbyId are different.
Here's what the editor-in-chief brings you about how to learn javascript quickly