I am trying to run a calculator with smallest possible JavaScript code bits. I am using jQuery to further minimize my script section.
But my eval() method is not working though alert(executed) present just next to it is working fine! What wrong am I doing? Take a look at what I've tried so far!
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  <meta charset="UTF-8" />
  <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.js"></script>
  <meta name="viewport" content="wclassth=device-wclassth, initial-scale=1.0">
  <style>
    .inp {
      font-weight: bolder;
      font-size: 5vw;
      width: 13vw;
      height: 13vw;
      margin-bottom: 2vw;
      margin-top: 2vw;
    }
    
    input:hover {
      color: red;
    }
  </style>
</head>
<body>
  <p>
    Answer will be shown here:
  </p>
  <br></br><br></br>
  <table style="background:black; padding:2vw; width:60vw; margin-left:20vw;">
    <th>
      <div id="display" style="width:56vw; height:15vw; background:skyblue; font-weight:bolder; font-size:5vw; color:red;"></div>
    </th>
    <tr>
      <td>
        <input class="inp" type="button" value="1" />
        <input class="inp" type="button" value="2" />
        <input class="inp" type="button" value="3" />
        <input class="inp" type="button" value="+" />
      </td>
    </tr>
    <tr>
      <td>
        <input class="inp" type="button" value="4" />
        <input class="inp" type="button" value="5" />
        <input class="inp" type="button" value="6" />
        <input class="inp" type="button" value="-" />
      </td>
    </tr>
    <tr>
      <td>
        <input class="inp" type="button" value="7" />
        <input class="inp" type="button" value="8" />
        <input class="inp" type="button" value="9" />
        <input class="inp" type="button" value="*" />
      </td>
    </tr>
    <tr>
      <td>
        <input class="inp" type="button" value="." />
        <input class="inp" type="button" value="0" />
        <input class="inp" type="button" value="/" />
        <input class="inp" type="button" value="ans" />
      </td>
    </tr>
  </table>
  <script>
    $(function() {
      $("input.inp").on("click", function() {
        if ($(this).val() != "ans") {
          var solve = $("#display").append($(this).val());
        }
        if ($(this).val() == "ans") {
          var result = eval(solve);
          $("p").html(eval(result));
          alert("executed");
        }
      });
    });
  </script>
</body>
</html>Edit: There were some syntax error in this code, which I hope is now fixed.

TypeError: solv.val is not a functionsolvis a number (actually, technicallyNaN, which is Not a Number)$("#display").append()returns$("#display")so will not be a number for parseInt to parse - your parseInt should be aroundsolv.val()