Blogger Information
Blog 54
fans 4
comment 1
visits 54908
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
getElementById
神仙不在的博客
Original
941 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>getElementById</title>
</head>
<body>
<p id="big">这是一个段落</p>
<p>这飒飒大苏打一个段落</p>
<p>这也是的是的落</p>
<p>这也实打实大苏打实打实落</p>
<script>
var p = document.getElementById('big');
    console.log(p);
    console.log(typeof p);
   console.dir(p);
</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

小括号里面要加''号。

document.getElementById('big');   方法要有返回值的,返回值是一个object对象。

console.log(p);      查看p
console.log(typeof p);     查看p类型
console.dir(p);      查看p的所有属性

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post