jquery - How to toggle a bootstrap alert on and off with button click? -
i want display alert box multiple times button click event without having refresh page alert box shows once. if want show alert box again, have refresh page.
currently if render bootstrap alert on page, when close it, div container of alert gone page. when click button again, doesn't show anymore. have been doing following on close button make hide instead of delete div container of alert.
<button class="close" onclick="$('#alertbox').hide();; return false;">×</button>
i wonder if using data-toggle or data-dismiss in bootstrap can make sort of toggle effect working without going through own custom javascript handlers.
i've had same problem: don't use data-dismiss
close button , work jquery show()
, hide()
:
$('.close').click(function() { $('.alert').hide(); })
now can show alert when clicking button using code:
$('.alert').show()
hope helps!
Comments
Post a Comment