2014-07-22 28 views
0
function xava(target_url, elementID) { 
    jQuery(elementID).animate({ 
     opacity: 0.25, 
     left: "+=135" 
    }, 1500); 
    window.location.href = target_url; 
} 
jQuery('[id^="nav-arrow"]').click(function() { 
    elementID = jQuery(this).attr('id'); 
    url = jQuery(this).attr("alt"); 
    xava(url, elementID); 
}); 

我試圖從屏幕上將圖像製作成動畫,當查看器單擊圖像然後重定向到頁面時會淡出圖像。除了動畫以外,這段代碼的所有部分都在工作 - 任何想法!提前jQuery動畫API不適用於我

回答

0

使用animate callback jQuery中

function xava(target_url, elementID) { 
    jQuery(elementID).animate({ 
      opacity: 0.25, 
      left: "+=135" 
     }, 1500, function() { 
       window.location.href = target_url; 
    }); 
} 

jQuery('[id^="nav-arrow"]').click(function (event) { 
    event.preventDefault(); 
    elementID = jQuery(this).attr('id'); 
    url = jQuery(this).attr("alt"); 
    xava(url, elementID); 
}); 
0

感謝嘗試這種方式

function xava(target_url, elementID) { 
    jQuery(elementID).animate({ 
     opacity: 0.25, 
     left: "+=135" 
    }, 1500,function(){ 
     window.location.href = target_url; 
    }); 
} 
+0

我試過,但沒有工作:( –

相關問題