遍历输出图片加hover

1.

$(".icon a>div").hover(function () {
            var slls = $(this).attr("class");
            slls = slls.replace("hi", "");
            $(this).css({ "background": "url(<%=site.path.themepath %>images/hicon" + slls + "h.jpg) no-repeat center #fff" });

         }, function () {
             var slls = $(this).attr("class");
             slls = slls.replace("hi", "");
             $(this).css({ "background": "url(<%=site.path.themepath %>images/hicon" + slls + ".jpg) no-repeat center #fff" });
        });

2.

for (var i = 1; i < 6; i++) {
            $(".icon a:eq(" + (i - 1) + ")>div").css({ "background": "url(<%=site.path.themepath %>images/hicon" + i + ".jpg) no-repeat center #fff" });
        }
        var iconhover = new Array(1, 2, 3, 4, 5);
        for (var j = 0; j < 5; j++) {
            $(".icon a:eq(" +j+ ")>div").hover(function () {
                var slls = $(this).attr("class");
                slls = slls.replace("hi", "");
                $(this).css({ "background": "url(<%=site.path.themepath %>images/hicon" + slls + "h.jpg) no-repeat center #fff" });

            }, function () {
                var slls = $(this).attr("class");
                slls = slls.replace("hi", "");
                $(this).css({ "background": "url(<%=site.path.themepath %>images/hicon" + slls + ".jpg) no-repeat center #fff" });
            });
        
        
        }
    });
  

 

 

posted @ 2017-05-22 17:09  飞鱼0725  阅读(292)  评论(0编辑  收藏  举报