您的位置:首页 > Web前端 > JavaScript

js部分基础知识

2016-04-01 12:06 561 查看
1.innerHTML:

利用js向html中嵌入html代码。

eg:

<html>

<head>

<title>javascript</title>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width; initial-scale=1.0">

<style>

#cicle {

width:200px;

height:200px;

border-radius:100px;

background:red;

}

</style>

</head>

<body>

<input type="text" id="mytext" value="aaa" />

<div id="cicle"></div>

<div id="what">who am i?</div>

<div id="creattext"></div>

<button id="change">change p text</button>

<script type="text/javascript">

var text = document.getElementById("mytext").value;

document.getElementById("change").onclick = function() {

text = document.getElementById("mytext").value;

document.getElementById("what").innerHTML = document.getElementById("what").innerHTML

+ "i am bob!";

//document.getElementById("creattext").innerHTML = "<ul><li>asd</li><li>zxc</li></ul>"

document.getElementById("cicle").style.display = "none";

document.getElementById("creattext").innerHTML = text;

}

</script>

</body>

</html>

2.Date.now():获取系统当前时间,单位是毫秒。

3.function():

两种形式:

1>function() {};

2>function make() {};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: