鼠標移入移出雙擊單擊事件

qq交流羣: 581478349 

<!DOCTYPE html>
<html>

	<head>
		<!--中文-->
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	</head>

	<div id="xuanzhuang">效果</div>


	</body> 
	<script type="text/javascript">

		//函數
		function aaa() {
			//鼠標移入
			document.getElementById("xuanzhuang").onmouseover = function() {
				console.log(this)
				document.getElementById("xuanzhuang").style.backgroundColor = "green";
			}
			//鼠標移出
			document.getElementById("xuanzhuang").onmouseout = function() {
				console.log(this)
				document.getElementById("xuanzhuang").style.backgroundColor = "red";
			}
			//單擊
			document.getElementById("xuanzhuang").onclick = function() {
				console.log(this)
				document.getElementById("xuanzhuang").style.backgroundColor = "yellowgreen";
			}
			//雙擊
			document.getElementById("xuanzhuang").ondblclick = function() {
				console.log(this)
				document.getElementById("xuanzhuang").style.backgroundColor = "#ccc";
			}
		}
		//調用函數
		aaa();

		
	</script>

</html>

承接web前端開發:

v:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章