我想飛行文本。我正在使用的代碼: -使用jQuery將文本飛到特定的div
var cart = jQuery('.flying-shopping-cart');
var texttodrag = jQuery(this).html();
if (texttodrag) {
var textclone = texttodrag.clone()
.offset({
top: texttodrag.offset().top,
left: texttodrag.offset().left
})
.css({
'opacity': '0.5',
'position': 'absolute',
'height': '150px',
'width': '150px',
'z-index': '100'
})
.appendTo(jQuery('body'))
.animate({
'top': cart.offset().top + 10,
'left': cart.offset().left + 10,
'width': 75,
'height': 75
}, 1000, 'easeInOutExpo');
setTimeout(function() {
cart.effect("shake", {
times: 2
}, 200);
}, 1500);
textclone.animate({
'width': 0,
'height': 0
}, function() {
jQuery(this).detach()
});
}
但它顯示TypeError: texttodrag.clone is not a function
。它適用於圖像,但適用於文本。請幫我
您想先解決控制檯錯誤。 –
請提供HTML也或jsfiddle –
我沒有看到在您的代碼中使用變量'imgtodrag'..嘗試創建一個小提琴,所以我們可以找到它。我也懷疑'imgtodrag'不是一個jQuery變量..所以嘗試像'$(imgtodrag).clone()' – Praveen