Jquery error on click slide down

2019-07-28 18:58发布

问题:

I am trying to get a box to drop down on the click of a link. This is my JS function

<script language = 'javascript'>
      function toggleInteractlogin(x)
               {
    if($('#' + x).is(":hidden"))
    {
       $('#'+x).slideDown(200);
      }
      else
     {
    $('#'+x).hide();
    }
    $('Interactlogin').hide();


    }
    </script>

Whenever i click on the actual link itself nothing slides down.

 <div class='buttons'><a href  = '#' onclick = "return false" onmousedown =         "javascripttoggleInteractlogin('login')"class='regular' name='save'> Log In </div></a>

Any help is appreciated

回答1:

there should be a : between javascript and function name as below

javascript:toggleInteractlogin('login');


回答2:

</div> is closed in wrong position

EDIT:

Change this html

<div class='buttons'><a href  = '#' onclick = "return false" onmousedown =         "javascripttoggleInteractlogin('login')"class='regular' name='save'> Log In </div></a>

to this html

<div class='buttons'>
    <a href='#' onclick="return false" onmousedown="javascripttoggleInteractlogin('login')" class='regular' name='save'>Log In</a>
</div>