kingjordan

鼠标事件

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	
	<body>
		<div>
			<button onmousedown="whichButton(event)">点击</button>
		</div>
	</body>
	<script type="text/javascript">
		
		function whichButton(event)
		{
			var btnNum = event.button;
			if (btnNum==2)
			{
				alert("您点击了鼠标右键!")
			}
			else if(btnNum==0)
			{
				alert("您点击了鼠标左键!")
			}
			else if(btnNum==1)
			{
				alert("您点击了鼠标中键!");
			}
			else
			{
				alert("您点击了" + btnNum+ "号键,我不能确定它的名称。");
			}
		}
	
	</script>
</html>

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-06-10
  • 2021-12-03
  • 2022-12-23
  • 2022-01-10
  • 2021-04-29
相关资源
相似解决方案