Home > Web Front-end > JS Tutorial > body text

Instance method of synchronizing text box content with JS code_javascript skills

WBOY
Release: 2016-05-16 17:29:03
Original
1065 people have browsed it

HTML code:

Copy code The code is as follows:



         <script> /alert("Synchronization successful"); <br> } <br> //Perform synchronization<br> setInterval(synchronize,500);//Synchronization interval, synchronized every 0.5 seconds <br> </script>


Entering characters in the second input box will automatically synchronize to the first input box.


First input box:


Second input box:




Save the above HTML code into an html format file, open it with a browser, and you can see the effect. Note: Some browsers prohibit the execution of local scripts for security reasons, please click "Run".
In the process of searching for information, I found that not only the change event can be processed, but other events can also be processed. For example: keyup event, etc. Here is another example snippet:



Copy code
The code is as follows: // This is not an immediate change
//This is an immediate change, but it will not be detected if you operate it with the mouse cursor, so you can combine the upper and lower two.




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