What's the difference between getElementById and getElementsByClassName
<p>I know maybe is not the right way of using the <code>getElementsByClassName</code>. For example the code below doesn't work as it is ¿why?, but when change <code>getElementsByClassName("demo")</code> for <code>getElementById("demo2")</code> does work</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;p&gt;Click the button.&lt;/p&gt;
&lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;
&lt;p class="demo" id="demo2"&gt;anything&lt;/p&gt;

&lt;script&gt;
function myFunction() {
var str = "How are you doing today?";
var res = str.split(" ");
document.getElementsByNameClass("demo").innerHTML = res;
}
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>