天天看點

對節點操作的思想

<!DOCTYPE html>
<html>
<body>
<!-- onmouseover 這種為固定值用法,後面跟着 函數名字, 在<script>裡調用 this 表示參數,這裡寫了,function裡面也要寫 -->
<div onmouseover="mOver(this)" onmouseout="mOut(this)" style="background-color:green;width:120px;height:20px;padding:40px;color:#ffffff;">把滑鼠移到上面</div>

<script>
    var div = document.querySelector('div')
function mOver(div)
{
div.innerHTML="歡迎滑鼠移入"
}

function mOut(div)
{
div.innerHTML="感謝滑鼠移出"
}
</script>
</body>
</html>