Home  >  Article  >  Web Front-end  >  jQuery displays mouse pointer position and keyboard ASCII code in real time_jquery

jQuery displays mouse pointer position and keyboard ASCII code in real time_jquery

WBOY
WBOYOriginal
2016-05-16 15:07:541120browse

This article uses jquery technology to realize the mouse pointer position and keyboard ASCII code. The code is simple and easy to understand. Please see below for the specific content.

jQuery displays mouse pointer position and keyboard ASCII code in real time_jquery

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
$(document).mousemove(function(e) {
$("span").html("X:" + e.pageX + "Y:" + e.pageY + "事件" + e.type);
//不行 document.write("X:" + e.pageX + "Y:" + e.pageY + "事件" + e.type);
});
});
</script>
</head>
<body>
<span></span>
</body>
</html>

Press A

jQuery displays mouse pointer position and keyboard ASCII code in real time_jquery

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
$(document).keydown(function(e) {
$('span').html(e.which);
})
});
</script>
</head>
<body>
<span></span>
</body>
</html>

The above content is the jQuery that the editor introduces to you in real-time display of the mouse pointer position and keyboard ASCII code. I hope it will be helpful to everyone. For more knowledge, please pay attention to the official website of Script House. The site has new content updated every day!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn