代码拉取完成,页面将自动刷新
<!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>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。