Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created April 22, 2013 11:39
Show Gist options
  • Save chikoski/5434101 to your computer and use it in GitHub Desktop.
Save chikoski/5434101 to your computer and use it in GitHub Desktop.
body{
background-color: white;
}
.mouseover{
background-color: rgb(255, 255, 0);
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>マウスを重ねるときに背景色を変えるデモ</title>
</head>
<body>
<div id="mouseover">マウスを重ねてみて!</div>
</body>
</html>
var mouseOver = function(event){
var elm = document.getElementById("mouseover");
elm.setAttribute("class", "mouseover");
};
var mouseOut = function(event){
var elm = document.getElementById("mouseover");
elm.setAttribute("class", "");
};
var target = document.getElementById("mouseover");
target.onmouseover = mouseOver;
target.onmouseout = mouseOut;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment