Home > Web Front-end > Front-end Q&A > Is there an oninput event in jquery?

Is there an oninput event in jquery?

WBOY
Release: 2022-06-14 19:03:01
Original
2748 people have browsed it

There is no oninput event in jquery. This event is triggered when the user inputs and exists in HTML and JavaScript. In JavaScript, you can use the addEventListener() method to set the oninput event. The syntax is "<element oninput="myScript">" or "object.addEventListener("input", myScript);".

Is there an oninput event in jquery?

The operating environment of this tutorial: Windows 10 system, jquery3.6.0 version, Dell G3 computer.

Is there an oninput event in jquery?

The oninput event is triggered when the user inputs.

This event is triggered when the value of the or

Tips: This event is similar to the onchange event. The difference is that the oninput event is triggered immediately when the element value changes, while onchange is triggered when the element loses focus. Another difference is that the onchange event also works on and

Syntax

HTML:

<element oninput="myScript">
Copy after login

JavaScript:

object.oninput=function(){myScript};
Copy after login

JavaScript, use addEventListener() method:

object.addEventListener("input", myScript);
Copy after login

Example As follows:

<body>
<p>在文本框中尝试输入触发函数。</p>
<input type="text" id="myInput" oninput="myFunction()">
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myInput").value;
    document.getElementById("demo").innerHTML = "你输入的是: " + x;
}
</script>
Copy after login

Output results:

Is there an oninput event in jquery?

Video tutorial recommendation: jQuery video tutorial

The above is the detailed content of Is there an oninput event in jquery?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template