结合使用HTML和jQuery实现此功能,并在按ENTER键后触发-
<!DOCTYPE html>
<html>
<head>
<script src = "https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('input').bind("enterKey",function(e){
alert("Enter key pressed");
});
$('input').keyup(function(e){
if(e.keyCode == 13)
{
$(this).trigger("enterKey");
}
});
});
</script>
</head>
<body>
<input type = "text">
<p>Press Enter key in the above input text.</p>
</body>
</html>