0

i am trying to animate a div using this code

var home_news_side = $('#home_news_side');
var side_timer;
home_news_side.mouseenter(function() {
    console.info('asd');
    clearTimeout(side_timer);
    home_news_side.animate({
        'margin-left': 0
    }, 800);
}).mouseleave(function() {
    side_timer = setTimeout(function() {
        home_news_side.animate({
            'margin-left': '-404px'
        }, 800);
    }, 800);
});

But its not working.... and if i try to force in te console like this:

$('#home_news_side').animate({
        'margin-left': 0
    }, 800);

i am getting this message

TypeError: Object # has no method 'animate'

here is the link to see the error Error link

Obs: i put a display none in the div until i fix this problem...

Neto Braghetto
  • 1,371
  • 1
  • 15
  • 30
  • include jquery.js files – Sridhar R Oct 29 '13 at 11:27
  • It's possible that the WordPress theme you are using has an element with id=sidebar. Unless a global variable with the same name has been explicitly defined, a global variable will be created for each element that has an id. So, the first test is unreliable. For example, evaluating window.sidebar on the stackoverflow page will be true even in Chrome, because the website uses an element with such an id. refer this link http://stackoverflow.com/questions/17747578/uncaught-typeerror-object-htmldivelement-has-no-method-addpanel?rq=1 – Sridhar R Oct 29 '13 at 11:28
  • in which file do you have this code – Arun P Johny Oct 29 '13 at 11:31
  • it looks like somebody is changing the value of `home_news_side` to a dom reference instead of a jQuery wrapper – Arun P Johny Oct 29 '13 at 11:33
  • Do you really need 40 javascript files that takes about five minutes to load on one site? In which of all those files did you add the code ? – adeneo Oct 29 '13 at 11:34
  • i dont need, but it is a ecommerce-platform and i don't have access to change this =(..... Arun P Johny - the file is v3_home.js – Neto Braghetto Oct 29 '13 at 11:38

1 Answers1

0

Wordpress uses jQuery noconflict mode by default, that means all code blocks must start with some sort of document ready function that uses jQuery and not $.

Your file starts with :

$(function() { ...

change that to

jQuery(function($) { ...

Wordpress Codex reference

adeneo
  • 312,895
  • 29
  • 395
  • 388