DEV Community

kerrybli
kerrybli

Posted on

Help me.Even without typing in the box still it's showing the result as Even

Code

```<!DOCTYPE html>





TEST

<input type="text" id="even" required placeholder="enter a number"><br>
<input type="button" value="Get Results" id="getResult" onclick="evenfun()">

<br> function evenfun(){<br> var num = document.getElementById(&quot;even&quot;).value=0;</p> <div class="highlight"><pre class="highlight plaintext"><code>if(num %2 == 0){ document.write("Even"); }else { document.write("odd"); } </code></pre></div> <p>}<br> <script><br> </body><br> </html>```<br> </p>

Top comments (0)