buttom.html 698 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>

	<input id='bc' type="button">Click</input>



	<div id='msg'></div>


	<script type="text/javascript">
		
		let bc=document.getElementById('bc');
		let msg=document.getElementById('msg');
		bc.addEventListener('mouseup',(e) => {

			switch (e.button){
				case 0:
					msg.textContent = 'Left mouse button cliccked.';
					break;
				case 1:
					msg.textContent= 'Middle mouse button cliccked.';
					break;
				case 2:
					msg.textContent= 'Right mouse button cliccked.';
					break;
				default:
				
					msg.textContent='Unkown mouse button code'+$(event.button);		
			}
		})

	</script>

</body>
</html>