简体   繁体   English

在引导中显示警报不起作用

[英]Showing an alert in bootstrap is not working

Here is the code 这是代码

<script type="text/javascript">
window.setTimeout(function() {
$("#alert_message").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 10000);
</script>
<div id="alert_message" class="alert" style="width:100%;" >
<span>If download button does not work. Right click on the meme and click save as...</span><span class="close" style="float:right;" data-dismiss="alert">&times;</span>
</div>

Now on page load the alert appears. 现在在页面加载中,出现警报。 I wrote the following code to make it appear again on click of a check box. 我编写了以下代码,以使其在单击复选框时再次出现。

else if(document.getElementById('31').checked) {
src = 'http://qph.is.quoracdn.net/main-qimg-7212ce8aa821a3af3d91ee709f3fd7f1?convert_to_webp=true';
$( "#alert_message" ).toggle();
}

It does not become visible again with this code. 此代码不会再次变得可见。

use 采用

$("#alert_message").css("display", "none");

instead of 代替

$(this).remove();

then: 然后:

$(document).ready(function () {
       $("#31").on('click', clicked);
       function clicked() {
        if($('#31').is(':checked')) { 
        // your code 
       $("#alert_message").css("display", "block");
      // or $("#alert_message").toggle();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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