Home >Web Front-end >JS Tutorial >A small example of changing the CSS style by moving the mouse in and out_javascript skills

A small example of changing the CSS style by moving the mouse in and out_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:31:191475browse

A certain area on the web page changes the style when the mouse is moved in, and automatically restores the style when the mouse is moved out. It can be the border of a picture, or a piece of text can change color. Once you master the principle, it seems that you can create a richer and more vivid web page interaction effect. Here It mainly uses Js to control the DIV where the Hover tag is located to generate actions. It is also a good example for learning.


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]<script> window.onload = function () { var oDiv = document.getElementById("div1"); oDiv.onmouseover = function () { oDiv.className = "hover" }; oDiv.onmouseout = function () { oDiv.className = "" } }; </script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn