I want it to be when I enter a text field (or input field) and everything that I type is displayed in a div at the same time or just somewhere else on the page?
The stackoverflow site does this when we enter a question. When we enter a question, it shows what we type in the box below the text box. Hope my question makes sense!
Thanks in advance.
StackOverflow , , - keydown (), keypress keyup ( , ) . .
keydown
keypress
keyup
- keyup (keydown keypress). , key(press|down) - , , , . keyup, , . , keyup , , , . , :)
key(press|down)
$("textarea").bind('keyup keydown', function() { $("#target").html(this.val()); });
. .
.keydown() :
.keydown()
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('#foo').keydown(function() { $('#result').text($(this).val()); }); }); </script> </head> <body> <input type="text" name="foo" id="foo" /> <div id="result"></div> </body> </html>
... , .
View Source:
:
<script type="text/javascript"> $(function() { editorReady(1, heartbeat.answers); }); </script>
URL "editorReady". http://sstatic.net/js/question.js?v=b05e8725a843
Source: https://habr.com/ru/post/1756377/More articles:Creating dependencies in Xcode 4 - iphoneGet default programs - c ++JQuery Interface Fisheye Left Aligned Interface - jqueryhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1756375/where-can-i-download-microsoft-web-application-stress-tool&usg=ALkJrhiAK3rnOIZjqnufJUBqyar5nTjmXACustom replacement method? - javascriptWhy is this form acceptable, but another form causes a type error? - haskellDownload AJAX + Coldfusion - jqueryBookmarklet data transfer method - javascriptMySQL database does not exist, queries are automatically bridged to the correct db? - phpHow to edit the context menu of the QtWebKit context menu in Qt Creator? - c ++All Articles