JS基础语法1
作者:
洛洛kkkkkk | 来源:发表于
2017-04-18 19:31 被阅读0次<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JS基础语法</title>
<style type="text/css">
.redDiv{
width: 200px;
height: 200px;
background-color: red;
}
</style>
</head>
<body>
<div class="redDiv" id="first"></div>
</body>
<!--script是一个比较随便的标签,可以放在body下面,body里面,head里面等位置,script本身放在任何位置
都可以被执行。但是浏览器本身读取文件的时候有先后顺序,script标签放的比较靠前可能会导致浏览器还没
有读取到一些元素。
-->
<script type="text/javascript">
// 通过选择器获取一个标签(元素)。
// 元素.onclick = function(){};
// 给这个元素添加一个点击事件,点击之后执行等号后面的函数。
document.getElementById("first").onclick = function(){
//弹框
alert("欢迎加入") ;
};
console.log("我可以在控制台输出");
</script>
</html>
本文标题:JS基础语法1
本文链接:https://www.haomeiwen.com/subject/aisqzttx.html
网友评论