Skip to content

Instantly share code, notes, and snippets.

@myanmarlinks
Created September 26, 2017 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myanmarlinks/15693e7c3f10ad2bbfddf78ea079c1e6 to your computer and use it in GitHub Desktop.
Save myanmarlinks/15693e7c3f10ad2bbfddf78ea079c1e6 to your computer and use it in GitHub Desktop.
Get Element by ID
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM TEST</title>
</head>
<body>
<div id="container">
<div class="row">
<h1>Hello World</h1>
<a href="#">Click Here</a>
</div>
<div class="row">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum beatae quas praesentium. Distinctio hic vel nihil, eum facilis doloremque incidunt atque autem dolor est esse fugit tempora ea magni, quis.</p>
</div>
<div class="row">
<ul>
<li><a href="#">How are you</a></li>
<li><a href="#">How do you do</a></li>
<li><a href="#">What are you doing</a></li>
<li><a href="#">Where do you live</a></li>
</ul>
</div>
</div>
<script>
var container = document.getElementById("container");
container.style.backgroundColor = "#e3e3e3";
container.style.padding = "20px";
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment