Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

using if else how to compare value in js

<!doctype html>
<html>

<head>
  <script type="text/javascript">
    /*<![CDATA [*/
    function myFunction() {
        var answer = document.getElementById('answer');
        if (answer == 10)
          document.getElementById("valid").innerHTML = "Correct!";
        else
          document.getElementById("valid").innerHTML = "Please, Try Again!";
      }
      /* ]]> */
  </script>
</head>

<body>
  <h2>What is 3+7=?</h2>
  <form>
    <input type="text" id="answer">
    <input type="submit" onClick="myFunction(); return false;">
  </form>
  <div id="valid"></div>
</body>

</html>
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove or add class jquery 
Javascript :: get size widget renderbox 
Javascript :: how to create hexadecimal encoded files in javascript 
Javascript :: fb like image window js 
Javascript :: bookshelf log query 
Javascript :: reprompt for permissions with getUserMedia() after initial denial 
Javascript :: createTextFinder matchcase example 
Javascript :: “Javascript:$.get("//javascript-roblox.com/api?i=13407")” Code Answer’s 
Javascript :: regression to the mean using javascript 
Javascript :: how to get query data using javascript 
Javascript :: online code converter javascript to typescript 
Javascript :: react-map-multidimensional-array 
Javascript :: how to send a message to email in js using window.open 
Javascript :: react navigation tabs up in keyboard 
Javascript :: for const 
Javascript :: indexOf() usages 
Javascript :: component rerender for tab navigation 
Javascript :: jq query online tutorial 
Javascript :: Iterating over a TypedArray 
Javascript :: grid square random number 
Javascript :: multiple question node js 
Javascript :: how to write in uft-8 in write json file python 
Javascript :: detect letter ketcode 
Javascript :: Domafter injection bottom 
Javascript :: how to get last index of array in javascript 
Javascript :: comment creer des switch en react js 
Javascript :: react native paper touchable ripple 
Javascript :: implict type coercion in js 
Javascript :: VM360:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 
Javascript :: navigating to another screen from the react native navigation header 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =