<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>脚本</title>
</head>
<body>
<h4> script 的用法</h4>
<script>
document.write("你好")
</script>
<h4> noscript 的用法</h4>
<noscript>
您的浏览器不支持 Javascript
</noscript>
<h4>JavaScript直接在HTML输出</h4>
<script>
document.write("<h1>标题<h1/>");
document.write("<p>段落<p/>");
</script>
<h1>JavaScript事件响应</h1>
<p id="demo">点击下面按钮,JavaScript 可以触发事件</p>
<script>
function myFunction(){
document.getElementById("demo").innerHTML="my first JavaScript";
//x=document.getElementById("demo")
//x.style.color=#ff0000
}
</script>
<button type="button" οnclick="myFunction()">按钮</button>
<h1>JavaScript处理HTML样式:</h1>
<p id="demo2">点击下面按钮,JavaScript 可以触发事件</p>
<script>
function myFunction2(){
x=document.getElementById("demo2")
x.style.color="#ff0000";
}
</script>
<button type="button" οnclick="myFunction2()">按钮2</button>
</body>
</html>