网络编程 
首页 > 网络编程 > 浏览文章

使用mouse事件实现简单的鼠标经过特效

(编辑:jimmy 日期: 2025/12/29 浏览:3 次 )

代码超级简单,这里就不多BB了,直接奉上

复制代码 代码如下:
<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
    body,ul,li{margin:0; padding:0; list-style:none}
    ul li{width:100px; height:100px; border:1px solid #f00; float:left; margin:50px 10px; background-color:#ffffff;}
    ul li.current{border:1px solid #dfdfdf; background-color:#ff0000;}
</style>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.min.js"> </head>
<body>
    <h1>鼠标经过下面的块</h1>
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</body>
</html>
<script type="text/javascript">
    $("ul li").mouseover(function()
    {
         $(this).addClass("current");
    }).mouseout(function()   
    {
        $(this).removeClass("current");       
    });
</script>

非常简单的代码,小伙伴们参考下,自由扩展,希望大家能够喜欢。

上一篇:js控制输入框获得和失去焦点时状态显示的方法
下一篇:js实现屏幕自适应局部代码分享
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap