次のjQueryがあります
$(document).ready(function(){
var vH=$('#background').height();
var vW=$('#background').width();
var vT=$('#background').offset().top;
var vL=$('#background').offset().left;
$('#test').mousemove(function(e){
var ypos=e.pageY-vT;
var xpos=e.pageX-vL;
var y=Math.round(ypos/vW*1500);
var x=Math.round(xpos/vH*200);
$('#test').val(x+' , '+y);
$('#background').css({backgroundPosition: x+'% '+y+'%'});
});
});
マウスを id="test" の div の上に移動すると、背景が移動します。ここで、マウスをどこに移動しても背景が移動するように変更したいと思います。
これを行う方法はありますか?または、複数の div を使用して次のようなものを取得することは可能ですか:
$('#test', '#test2').mousemove(function(e){
あなたの助けに本当に感謝します!