我想實現
我想div的背景圖片來改變上述的div內的鏈接的鼠標懸停什麼。更改背景圖片
例
<div id="container">
<a href="" id="linktomouseover"></a>
</div>
我已經試過
我已經試過交換使用jQuery的背景圖像:
<script language="javascript" type="text/javascript">
jQuery('#linktomouseover').mouseover(function()
{
jQuery('#container').css("background-image", "url(bg-b.png)");
});
</script>
誰能告訴我對我缺少的是什麼嗎?
解決方案
<style>
#container{
width:100%;
height:100%;
background-image:url(http://thumbs.dreamstime.com/thumblarge_536/12838649102C1cO5.jpg);
}
</style>
<div id="container"><br><br>
<a href="" id="linktomouseover">hover</a>
</div>
<script>
jQuery('#linktomouseover').hover(function()
{
jQuery('#container').css("background-image",
"url(http://static4.depositphotos.com/1011237/285/i/450/dep_2853473-Background-for-your-web-store.jpg)
");
}).mouseleave(function(){
jQuery('#container').css("background-image", "url(http://thumbs.dreamstime.com/thumblarge_536/12838649102C1cO5.jpg)");
});
</script>
你是對的:) – Rafay
這不是刪除的原因:)但是我看到更多的錯誤:p – genesis
點擊?我認爲你的意思是鼠標懸停或我錯過了什麼? –