遍历输出图片加hover
Posted 飞鱼0725
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了遍历输出图片加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" }); }); } });
以上是关于遍历输出图片加hover的主要内容,如果未能解决你的问题,请参考以下文章