我需要停止使用jquery鼠標懸停在一個圓圈中的多個圖像旋轉,而不指定時間間隔。我嘗試了兩種方式。如何停止在沒有時間間隔懸停期間使用jquery的所有圖像旋轉
1. stops the one image using the div id in hover.
$(document).ready(function() {
$('#friends2').hover(function() {
$(this).stop();
}, function() {
moveit();
});
2. created a common class id 'a' for images and the stops in hover.
$(document).ready(function() {
$('.a').hover(function() {
$(this).stop();
}, function() {
moveit();
});
my script as
<script type="text/javascript">
var p = 0;
function moveit() {
p += .01;
var r = 165;
var xcenter = 550;
var ycenter = 300;
var newLeft = Math.floor(xcenter + (r* Math.cos(p+90)));
var newTop = Math.floor(ycenter + (r * Math.sin(p+90)));
var newLeft1 = Math.floor(xcenter + -(r* Math.cos(p+120)));
var newTop1 = Math.floor(ycenter + -(r * Math.sin(p+120)));
var newLeft2 = Math.floor(xcenter + (r* Math.cos(p+390)));
var newTop2 = Math.floor(ycenter + (r * Math.sin(p+390)));
$('#friends').animate({
top: newTop,
left: newLeft,
}, 10, function() {
moveit();
});
$('#friends2').animate({
top: newTop1,
left: newLeft1,
},10, function() {
moveit();
});
$('#friends3').animate({
top: newTop2,
left: newLeft2,
},10, function() {
moveit();
});
}
問題是盤旋不適用於所有圖像..是否有任何其他方法..建議??
現場演示中看到此鏈接:http://jsfiddle.net/nanoquantumtech/KRBaF/ – Thulasiram