$('#user_text').keyup(function(){ var user_text = $('#user_text').val(); $('#user_text_feedback').html(user_text); });
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jquery</title> <link rel="stylesheet" type="text/css" href="css/style.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <input type="text" id="user_text" value="hey"><br /> <span id="user_text_feedback"></span> </body> </html>
I'm using google chrome as my default browser. I tried to execute the above code but I'm not getting the required output.I also tried using keydown instead of keyup I wasn't getting the proper output
Change $('#user_link')
to $('#user_text')
:
$('#user_text').keyup(function(){
var user_text = $('#user_text').val();
$('#user_text_feedback').html(user_text);
});
Working here you should use #user_text
:
$('#user_text').keyup(function(){ var user_text = $('#user_text').val(); $('#user_text_feedback').html(user_text); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jquery</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <input type="text" id="user_text" value="hey"><br /> <span id="user_text_feedback"></span> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/init.js"></script> </body> </html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.