简体   繁体   中英

Basic jQuery slideDown() not working

Super simple question - I'm new to jQuery so I'm a little bit stupid with it.

https://jsfiddle.net/ve5f3oeb/

<a href="#" id="forgotten-show">I have forgotten my password ></a></div>

        <form class="forgotten-pw" action=""><!-- This still needs to dropdown from clicking the #forgotten-show link above -->
            <input type="email" placeholder="Your email"><!-- Prefill this field with their email address as they type just in case they have forgotten their email -->
            <div class="row inline-center">
                <input type="submit" value="Send password">
            </div>
            <p class="pw-reminder-sent">Your password has been sent</p>
        </form>

$("#forgotten-show").click(function() {
  $(".forgotten-pw").slideToggle( "slow", function() {
  });
});

I have display: none; set on the form so I want to toggle slide up and down. Surely the jQuery is sound as I took it from the documentation. What am I missing?

UPDATE: OK my JSFIDDLE went tits up.

My issue is the code works when the jQuery is inside a script tag on the same page but not working from a linked JS file.

I know the file is linked properly because I have other things going on that work.

Can it be that you forgot to include the jQuery library?

Try

https://jsfiddle.net/ve5f3oeb/2/

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

You did not include the jQuery library.

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>

Updated fiddle:

https://jsfiddle.net/ve5f3oeb/3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM