1 Star 1 Fork 0

levy9527 / practice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
id.html 914 Bytes
一键复制 编辑 原始数据 按行查看 历史
levy9527 提交于 2017-01-23 18:18 . id也可以select元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>use id to select element</title>
<style>
section {
margin-top: 10px;
}
</style>
<script>
//var foo = function(){}
var foo = 'foo'
</script>
</head>
<body>
<section>
<p>覆盖失败</p>
<div id="window">window</div>
<div id="document">document</div>
</section>
<section>
<p>使用id引用</p>
<div id="foo">id: foo</div>
<div id="bar">id: bar</div>
<div id="two-word">id: two-word</div>
</section>
<section>
<p>使用name引用</p>
<form action="#" name="form">表单</form>
<img src="" alt="img" name="img">
</section>
<section>
<div>可在控制台测试变量</div>
<div id="result"></div>
<div>two-word的引用需要使用: window['two-word']</div>
</section>
<script>
var bar = 'bar'
result.textContent = 'foo is ' + foo + ', bar is ' + bar
</script>
</body>
</html>
JavaScript
1
https://gitee.com/levy9527/practice.git
git@gitee.com:levy9527/practice.git
levy9527
practice
practice
master

搜索帮助