JavaScript Bootstrap alert not working when clicked again bootstrap alert not working,bootstrap alert close not working,bootstrap

Facing a very silly issue. I am showing alert message on a button click. It works perfectly at first click but then it is not working on next clicks,

Here is my code : http://jsfiddle.net/nre6fbm5/

HTML

<body>
  <div class="container">
    <h2>Dismissal Alert Messages</h2>
    <button>Send Message</button>
    <div class="alert alert-danger fade alert-conatiner">
      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> Error! Can not proceed.
    </div>

  </div>
</body>

JS

$(document).ready(function() {
  $('button').click(function() {
    $(".alert").delay(1000).addClass("in").fadeOut(4000);
  })
});

Thanks in advance!

Answer:1

One string solution:

$(".alert").delay(1000).addClass("in").toggle(true).fadeOut(4000);

Edit: The problem why it worked only once was that display: none was added by fadeout function. .toggle(true) will set display property to block just before the fadeout fires. See more about this:

.toggle()

.fadeOut()

Working code here : http://jsfiddle.net/hxxjgh63/

Answer:2

Hope this help, you have to remove class "in".

The second thing: style="display:none" auto added in ".alert" after fading out. Set this to empty

$(document).ready(function() {
  $('button').click(function() {
    $(".alert").delay(1000).addClass("in").fadeOut(4000);
    setTimeout(function(){      
        $(".alert").removeClass("in").css('display','');
    },5500);
  })
});

Your demo

Answer:3

in class not enough to show alert next time because it set display: none, you need to set fadeIn as you set fadeOut

$(document).ready(function() {
  $('button').click(function() {
    $(".alert").fadeIn().addClass('in').delay(4000).promise().done(function(){
    $(this).removeClass("in").fadeOut();
    });
  })
});

JSFiddle

Answer:4

i am very new to coding so please be gentle. i have been given a project by a college that i am studying at. to build an online interactive tutorial, very much in the same vane as codecademy and the ...

i am very new to coding so please be gentle. i have been given a project by a college that i am studying at. to build an online interactive tutorial, very much in the same vane as codecademy and the ...

  1. make html editor javascript
  2. make html editor

text content of bootstrap modal body flows outside. when long text without any space. I need a solution.text content should not overlapping when text is long <script src="https://ajax....

text content of bootstrap modal body flows outside. when long text without any space. I need a solution.text content should not overlapping when text is long <script src="https://ajax....

  1. text content bootstrap
  2. text content center bootstrap
  3. carousel with text content bootstrap
  4. bootstrap text content scroll

what is the easiest way to retrieve form values to send to localStorage as a JSON string? I started a function with a for loop but am stuck..any nudges are greatly appreciated(still very new to this) ...

what is the easiest way to retrieve form values to send to localStorage as a JSON string? I started a function with a for loop but am stuck..any nudges are greatly appreciated(still very new to this) ...

  1. send html form data to email
  2. send html form to email
  3. send html form to google sheets
  4. send html form data to email using php
  5. send html form as json
  6. send html form data
  7. send html form to javascript function
  8. send html form data to email using javascript
  9. send html form to email javascript
  10. send html form data to database
  11. send html form data to node js
  12. send html form data to python script
  13. send html form data to rest api
  14. send html form data to python
  15. send html form data to excel
  16. send html form data to text file
  17. send html form data to another page
  18. send html form to email php
  19. send html form data to whatsapp
  20. send html form data to sql database

I'm trying not to mutate an object within an object before setting it to state like this: isDraggable = () => { let steps = [...this.state.stepsData]; steps = steps.map(step => ...

I'm trying not to mutate an object within an object before setting it to state like this: isDraggable = () => { let steps = [...this.state.stepsData]; steps = steps.map(step => ...

  1. vuex mutation nested object