鼠标移动到P标签上时,改变文本和边框样式
<style type="text/css"> .onmouseover { color: red; border: 1px solid blue; cursor: hand; </style> <script type="text/javascript"> function over() { var p = document.getElementById("p"); //选择器className修改。 p.className = "onmouseover"; } function out() { var p = document.getElementById("p"); p.className = ""; } </script> <body> <p onmouseover="over()" onmouseout="out()" id="p">鼠标移动到P标签上时,改变文本和边框样式</p> </body>