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

js method to monitor text box status in real time_javascript skills

WBOY
Release: 2016-05-16 18:07:17
Original
1486 people have browsed it
Copy code The code is as follows:



<script> <br>//Function executed when the status changes<br>function handle( ) <br>{ <br>document.getElementById('msg').innerHTML = document.getElementById('txt').value; <br>} <br><br>//if("v"==" v") only returns true under IE, including IE8 <br>//if(/msie/i.test(navigator.userAgent)) can also effectively determine <br>if("v"=="v" ){ <br>//IE monitors the text box and assigns a function. There cannot be brackets after the function name <br>document.getElementById('txt').onpropertychange = handle; <br>}else{ <br>//Google The browser uses the add event function to add events to the text box and assign the method to be executed. Similarly, brackets cannot be added after the method name <br>document.getElementById('txt').addEventListener("input", handle); <br> } <br></script>
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