遍历输出图片加hover

时间:2024-10-09 14:05:27

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 = ; i < ; i++) {
$(".icon a:eq(" + (i - ) + ")>div").css({ "background": "url(<%=site.path.themepath %>images/hicon" + i + ".jpg) no-repeat center #fff" });
}
var iconhover = new Array(, , , , );
for (var j = ; j < ; 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