按下删除键(backspace)清除input框中的内容

<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<div>
			<di>
				<input type="text" id='pass' value="123" />
		</div>
		</div>
		<script src="http://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
		<script type="text/javascript">
			$(document).bind("keydown", function(e) {
     
				e = e ? e : event;
				if(e.keyCode == 8) {
     

					$('#pass').val("");
				}
			});
		</script>
	</body>

</html>

你可能感兴趣的:(jquery,js,html,javascript)