我有以下 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){
我真的很感谢你的帮助!