{"id":3501,"date":"2014-03-27T04:51:48","date_gmt":"2014-03-27T04:51:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/27\/jquery-fly-to-cart-animation-collection-of-common-programming-errors\/"},"modified":"2014-03-27T04:51:48","modified_gmt":"2014-03-27T04:51:48","slug":"jquery-fly-to-cart-animation-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/27\/jquery-fly-to-cart-animation-collection-of-common-programming-errors\/","title":{"rendered":"Jquery fly to cart animation-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to add fly to cart animation to woocommerce plugin, in order to get this I have used the following code<\/p>\n<pre><code>jQuery(document).ready(function(e){e(document).on(\"click\",\".add_to_cart_button\",function(){var t=e(this);if(t.is(\".product_type_simple, .product_type_downloadable, .product_type_virtual\")){\n\nvar cart = $('.widget_shopping_cart_content');\nvar imgtodrag = $('.event img').eq(0);\n        var imgclone = imgtodrag.clone()\n            .offset({\n            top: imgtodrag.offset().top,\n            left: imgtodrag.offset().left\n        })\n          .css({\n            'opacity': '0.5',\n                'position': 'absolute',\n                'height': '150px',\n                'width': '150px',\n                'z-index': '100',         \n        })\n\n            .appendTo($('body'))\n            .animate({\n            'top': cart.offset().top + 10,\n                'left': cart.offset().left + 10,\n                'width': 75,\n                'height': 75,  \n        });\nsetTimeout(function () {\n            cart.effect(\"shake\", {\n                times: 2\n            }, 200);\n        }, 1500);\n\n        imgclone.animate({\n            'width': 0,\n                'height': 0\n        }, function () {\n            $(this).detach()\n        });\n    }\n);\n<\/code><\/pre>\n<p>Every time I run this code I get error &#8220;Uncaught TypeError: Object # has no method &#8216;css&#8217; &#8220;, i have tried different methods of selecting the image but I get the same error every time.<\/p>\n<p>Any help or pin pointing me to the right direction will help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to add fly to cart animation to woocommerce plugin, in order to get this I have used the following code jQuery(document).ready(function(e){e(document).on(&#8220;click&#8221;,&#8221;.add_to_cart_button&#8221;,function(){var t=e(this);if(t.is(&#8220;.product_type_simple, .product_type_downloadable, .product_type_virtual&#8221;)){ var cart = $(&#8216;.widget_shopping_cart_content&#8217;); var imgtodrag = $(&#8216;.event img&#8217;).eq(0); var imgclone = imgtodrag.clone() .offset({ top: imgtodrag.offset().top, left: imgtodrag.offset().left }) .css({ &#8216;opacity&#8217;: &#8216;0.5&#8217;, &#8216;position&#8217;: &#8216;absolute&#8217;, &#8216;height&#8217;: &#8216;150px&#8217;, &#8216;width&#8217;: &#8216;150px&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3501","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3501","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3501"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3501\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}