Aviral Sacdheo
Aviral Sacdheo

Reputation: 13

JQuery keyup/down isn't working in chrome

$('#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

Upvotes: 0

Views: 146

Answers (2)

Quentin Roger
Quentin Roger

Reputation: 6538

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>

Upvotes: 0

Ashkan Mobayen Khiabani
Ashkan Mobayen Khiabani

Reputation: 34160

Change $('#user_link') to $('#user_text'):

$('#user_text').keyup(function(){
    var user_text = $('#user_text').val();
    $('#user_text_feedback').html(user_text);
});

Upvotes: 1

Related Questions