- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Execute a script when the element gets user input in HTML?
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 −
Example
<!DOCTYPE html> <html> <body> <p>Write your name below:</p> <input type = "text" id = "myid" oninput="display()"> <p id="test"></p> <script> function display() { var p = document.getElementById("myid").value; document.getElementById("test").innerHTML = "Your answer is " + p; } </script> </body> </html>
Advertisements