How to get value of HTML element in javascript?
<p>so I'm having trouble with getting the value of a specific field in my code - I made this pretty simple example to show my problem, here is the JSFiddle:
<a href="https://jsfiddle.net/c3jtg60v/" rel="nofollow noreferrer">https://jsfiddle.net/c3jtg60v/</a></p>
<p>The HTML:</p>
<pre><code>&lt;p id=&quot;theInput&quot;&gt;
   desired-value
&lt;/p&gt;
</code></pre>
<p>The Javascript:</p>
<pre><code>var value = document.getElementById(&quot;theInput&quot;).value;
console.log(value);
</code></pre>
<p>As is, I have assigned a <strong>p</strong> element with an id of &quot;theInput&quot;, and in it I have the desired value, that I want to make use of in my javascript.</p>
<p>At the moment, all I'm trying to do is console.log the value, but when I do this, all i get logged in the console is 'undefined'. What I really want to get logged to the console is &quot;desired value&quot;,</p>