admin管理员组文章数量:1396130
I have 7 thumbnail image menus.when user points(mouseover)
to a particular thumbnail, I want to change the background-image of <div>
to the regarding image of that thumbnail.
thumbnail images menu are in a diff div
I have 7 thumbnail image menus.when user points(mouseover)
to a particular thumbnail, I want to change the background-image of <div>
to the regarding image of that thumbnail.
thumbnail images menu are in a diff div
Share Improve this question asked Jun 21, 2010 at 12:56 nectarnectar 9,67736 gold badges82 silver badges101 bronze badges3 Answers
Reset to default 7Whats wrong with pure css?
div.thumbnail:hover {
background-image: url(image/in/question);
}
Simply change the div.thumbnail to reflect your div and class or id name (in case of id replace .
with #
)
You can use jQuery something like:
$(function(){
$('div.someclass').hover(function(){
$(this).addClass('hover_class');
}, function(){
$(this).addClass('mouseout_class');
}
);
});
Where you have specified the hover_class
and mouseout_class
in your style sheet with corresponding images eg
<style type="text/css">
.hover_class {
background-image: url(url 1);
}
.mouseout_class{
background-image: url(url 2);
}
</style>
do
$('#thumbnailimg').hover(function(){
$('#changeme').css('background-image', $(this).children('img').attr('src'));
}, function(){
$('#changeme').css('background-image', '');
});
本文标签: javascripthow to change div background image in mouse overStack Overflow
版权声明:本文标题:javascript - how to change div background image in mouse over? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744641650a2617158.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论