A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-oninput-event-attribute/ below:

HTML oninput Event Attribute - GeeksforGeeks

HTML oninput Event Attribute

Last Updated : 04 Aug, 2023

This attribute works when it gets user input value. This attribute mainly fires when the user change the value of <input> and <textarea> element. This attribute is quite similar to onchange attribute but the basic difference is that the oninput event attribute occurs immediately when the value of the element changes while the onchange attribute occurs when the element loses Focus. The other difference is that onchange attribute also works with the <select> element.

Supported Tags:

Syntax: 

<element oninput = "script">

Attribute Value: This attribute contains value script and it works when oninput event triggered. This attribute is supported by many HTML tags: <input type="password">, <input type="search">, <input type="text"> and <textarea>.

Example:  

HTML
<!DOCTYPE html>
<html>

<head>
    <title>oninput attribute</title>
    <style>
        body {
            text-align: center;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>oninput Attribute</h2>
    Enter some Text here: <input type="text" 
                                 id="GFG" 
                                 oninput="Geeks()">
    <p id="sudo"></p>



    <script>
        function Geeks() {
            let x = document.getElementById("GFG").value;
            document.getElementById("sudo").innerHTML =
                "Entered Text: " + x;
        }
    </script>
</body>

</html>

Output: 

Supported Browsers: The browser supported by oninput event attribute are listed below:  



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4