1 Star 1 Fork 0

levy9527 / practice

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
id.html 914 Bytes
Copy Edit Web IDE Raw Blame History
levy9527 authored 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>

Comment ( 0 )

Sign in to post a comment

JavaScript
1
https://git.oschina.net/levy9527/practice.git
git@git.oschina.net:levy9527/practice.git
levy9527
practice
practice
master

Search

184635 d8eb8a04 1850385 161156 f1cf3f24 1850385