开发者

Change CSS background image position of DIV from a separate link MOUSEOVER?

开发者 https://www.devze.com 2023-01-20 05:00 出处:网络
Is it possible to change CSS position of a background image with a DIV (\"omega\") from a separa开发者_开发百科te link (\"alpha\") with a MOUSEOVER?

Is it possible to change CSS position of a background image with a DIV ("omega") from a separa开发者_开发百科te link ("alpha") with a MOUSEOVER?

<a class="omega" href="#"></a>

<div id="alpha"></div>


Is JavaScript/jQuery ok? If so, something like this should work:

$('.omega').hover(function(){
    $('#alpha').css('backgroundPosition', '500px 150px');
}, function(){
    $('#alpha').css('backgroundPosition', '0px 0px');
});

The first function is for mouseover, the second one resets it when the mouse leaves. Admittedly, I haven't tried this, but in theory it should work. See jquery hover and jquery css for more info.

0

精彩评论

暂无评论...
验证码 换一张
取 消