javascript - Jquery animation doesn't work on id-specified divs? -


i'm going mad. question simple yet on comprehension reason.
this work (on every div of page, #example):

    $('#clickme').click(function() {         $('div').animate({left: '250px'});     }); 

but not:

    $('#clickme').click(function() {         $('#example').animate({left: '250px'});      }); 

i'm confused.

simply $('#example') invalid here. check

$('#clickme').click(function() {    if($('#example') && $('#example').length>0)    {      alert("o no available");      $('#example').animate({left: '250px'});       alert("oops animate worked");    }    else       alert("machine right");        }); 

you see either animate working or machine right. in later case have make #example available , bingo


Comments