Professional Documents
Culture Documents
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Manipulation</title>
<link rel="stylesheet" href="https://stackedit.io/style.css" />
</head>
<body class="stackedit">
<div class="stackedit__html"><h2 id="dom-manipulation">DOM Manipulation</h2>
<p><strong>Pre-Requisites:</strong><br>
For the rest of this cheatsheet, I will assume that you know HTML at an
intermediate level and understand CSS to some degree.</p>
<p><strong>What is the DOM?</strong><br>
<code>DOM</code> stands for <em>Document Object Model</em>. Basically, in the DOM,
the <em>whole</em> HTML structure of the webpage is referred to as the
<code>document</code> and each <em>HTML element</em> inside the <em>document</em>
is an <code>object</code>.</p>
<p><strong>How to manipulate HTML Elements?</strong><br>
We can do all sorts of things to HTML Elements including changing their inside
text, modifying the HTML contained within them, changing their attributes, changing
their styles etc.<br>
But to do all do this we must first access the element. Suppose we have the
following <em>HTML body structure:</em></p>
<pre class=" language-html"><code class="prism language-html"><span class="token
comment"><!--example 1.1--></span>
</html>