Execute a script when the element gets user input in HTML?

HTMLWeb DevelopmentFront End Technology

Use the oninput event attribute to trigger when an element gets user input. You can try to run the following code to implement oninput attribute −


<!DOCTYPE html>
      <p>Write your name below:</p>
      <input type = "text" id = "myid" oninput="display()">
      <p id="test"></p>
         function display() {
            var p = document.getElementById("myid").value;
            document.getElementById("test").innerHTML = "Your answer is " + p;
Published on 13-Mar-2018 17:54:05