- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>getYourCurrentInputValue</title>
- </head>
- <body>
- <div><input type="text" size="20" maxlength="25"></div>
- <div><p></p></div>
- <script type="text/javascript">
- var yourInput= document.getElementsByTagName('input')[0]
- if (document.addEventListener) {
- yourInput.addEventListener('input', write, false);
- } else if (document.attachEvent) {
- yourInput.attachEvent('onpropertychange', write);
- }
- function write() {
- document.getElementsByTagName('p')[0].innerHTML= yourInput.value;
- }
- </script>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/0605201512488.html
来源: http://www.codesnippet.cn/detail/0605201512488.html