s j s j - 2 years ago 82
Javascript Question

Jquery/javascript function issue

I have a javascript function doing some animation and its parameter is a parent selector.

function myFunction(a)
$("'"+a+">#one'").stop(true, true).animate({left:'30px'},1100);
$("'"+a+">#two'").stop(true, true).animate({left:'30px'},1100);

and the following line is calling that function.


but this is not working, can anyone tell me whats wrong in my code ?

Answer Source


function myFunction(a){
    $(a+">#one").stop().animate({left:30},1100); // <-- fixed selectors

$("#main").mouseleave(function(){ // <-- (immediate call: Wrong)
  myFunction("#main");            // <-- fn reference: OK!
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download