Home  >  Article  >  Web Front-end  >  The content of the input input box is obtained in real time

The content of the input input box is obtained in real time

php中世界最好的语言
php中世界最好的语言Original
2018-04-19 09:46:084636browse

This time I will bring you the real-time acquisition of the input input box content. What are the precautions for the real-time acquisition of the input input box content. The following is a practical case, let's take a look.

Real-time monitoring of the content of the input box! The event will be triggered only if the content of the input box changes. If the content of the input box does not change, the event will not be triggered!

The code is as follows:

<script type="text/javascript" src="jquery-3.2.1.js"></script>
<script type="text/javascript">
 function OnInput (event) {
  alert (event.target.value);
 }
 function OnPropChanged (event) {
  if (event.propertyName.toLowerCase () == "value") {
   alert (event.srcElement.value);
  }
 }
</script>
<form>
 用户名:<input name="user" type="text" oninput="OnInput (event)" onpropertychange="OnPropChanged (event)"/>
</form>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

JS implements evaluation star rating

##JS implements data validation and check box form submission

The above is the detailed content of The content of the input input box is obtained in real time. 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