Home  >  Article  >  Web Front-end  >  Is there an oninput event in jquery?

Is there an oninput event in jquery?

WBOY
WBOYOriginal
2022-06-14 19:03:012700browse

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">

JavaScript:

object.oninput=function(){myScript};

JavaScript, use addEventListener() method:

object.addEventListener("input", myScript);

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>

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!

Statement:
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