-1

I was looking to implement the helpful answer here but it isn't working for me in my browser or even in the code snippet here but works in jsfiddle http://jsfiddle.net/joydh7L0/2/

Basically the alert is always shown and the script doesn't seem to be working. Am a beginner so might be missing something very obvious. Any help appreciated!

Update: Based on a couple of comments on this I am using bootstrap and with that using their recommended jQuery link. Thanks!

"https://code.jquery.com/jquery-3.4.1.slim.min.js"

<!doctype html>
<html lang="en">

  <head>
  </head>
  <body>
    <button type="submit" class="btn btn-primary">Submit</button>

    <div class="alert alert-success" id="submitsuccess"   role="alert"> Thanks for letting us know!</div>
    <script>
      $(document).ready(function() {
        $(".alert").hide()
        $("button").click(function showAlert() {
          $(".alert").fadeTo(2000, 500).slideUp(500, function() {
            $(".alert").slideUp(500);
          })
        })
      })
    </script>
  </body>
rtrt1
  • 79
  • 2
  • 10

1 Answers1

0

Make sure you have included Jquery plugin.

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

also if using css framework like booststrap you can also include.

Tranquillity
  • 237
  • 2
  • 9
  • I am using bootstrap and have included the standard bootstrap recommendation – rtrt1 May 06 '20 at 21:50
  • [Here created sample](https://jsbin.com/gufamifonu/1/edit?html,js,output) check the html part, that you can run locally as well. – Tranquillity May 06 '20 at 22:16
  • @user13448168 were you able to solve with above resources? – Tranquillity May 07 '20 at 09:36
  • Thanks yes this worked. The two problems were, the default bootstrap jQuery link was "..slim.min.js" - with the slim version this did not work. And second, my jQuery plugin was declared at the bottom of the html file. When I moved it up (and used min.js) it worked. Many thanks for the help. – rtrt1 May 07 '20 at 15:56
  • @user13448168 if you wish you can like/vote my answer and comments. It will be great help. Thank you! – Tranquillity May 07 '20 at 15:58
  • done! though I am new so it doesn't show! Many thanks for the created sample that was super. – rtrt1 May 07 '20 at 16:00
  • @user13448168 okay will wait. Enjoy coding. – Tranquillity May 07 '20 at 16:05