<DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mydemo</title>
<style type="text/css">
body,#outer p {margin:0;padding:0;}
html,body {height:100%;}
#outer {border:20px black solid;background:black;width:200px;height:200px; margin:10px auto;}
#outer p {color: white;padding:10px;}
</style>
<script type="text/javascript">
window.onload = function() {
/*border,background,color,cursor*/
var oDiv = document.getElementById("outer");
var oP = document.getElementsByTagName("p")[0];
oDiv.onmouseover = function() {
this.style.cssText="border-color:red;background:white;cursor:crosshair";
oP.style.cssText = "color:red";
JS小案例(鼠标的移入移出)
最新推荐文章于 2024-07-12 16:27:40 发布
本文介绍如何使用JavaScript实现元素的鼠标移入和移出事件,通过添加和移除CSS类来改变元素样式,达到动态交互的效果。
摘要由CSDN通过智能技术生成