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

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

Apr 19, 2018 am 09:46 AM
input real time Obtain

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>
Copy after login

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get file extension in Python? How to get file extension in Python? Sep 08, 2023 pm 01:53 PM

How to get file extension in Python?

The combination of Java and WebSocket: how to achieve real-time video streaming The combination of Java and WebSocket: how to achieve real-time video streaming Dec 17, 2023 pm 05:50 PM

The combination of Java and WebSocket: how to achieve real-time video streaming

Where to get Google security code Where to get Google security code Mar 30, 2024 am 11:11 AM

Where to get Google security code

Using C++ to implement real-time audio and video processing functions of embedded systems Using C++ to implement real-time audio and video processing functions of embedded systems Aug 27, 2023 pm 03:22 PM

Using C++ to implement real-time audio and video processing functions of embedded systems

How to get the last element of LinkedHashSet in Java? How to get the last element of LinkedHashSet in Java? Aug 27, 2023 pm 08:45 PM

How to get the last element of LinkedHashSet in Java?

Java program to get the size of a given file in bytes, kilobytes and megabytes Java program to get the size of a given file in bytes, kilobytes and megabytes Sep 06, 2023 am 10:13 AM

Java program to get the size of a given file in bytes, kilobytes and megabytes

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecasting system

How to use Java Websocket to implement real-time weather forecast function? How to use Java Websocket to implement real-time weather forecast function? Dec 17, 2023 pm 05:10 PM

How to use Java Websocket to implement real-time weather forecast function?

See all articles