Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 15:07:54
Original
1151 people have browsed it

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>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template