在if语句</div>之后显示Bootstrap alert <div>

时间:2014-04-13 09:35:36

标签: javascript css twitter-bootstrap javascript-events

我希望这个div显示:

<div id="markers-added" class="alert alert-dismissable alert-success fade" >
   <button type="button" class="close" data-dismiss="alert">×</button>
   <div id="markers-added-message"><strong>Thanks!!!</strong> You have added a point.</div>
</div>

在此if语句之后:

if (True) {
        <   code here    >;
}

请帮忙!! 我用的代码是什么? 在用户能够做某事后,它是一个警报框。 谢谢!! PS。我知道jquery :(

CSS:

#markers-added {
    left: 50%;
    top: 40%;
    margin: 0 0 0 -200px;
    position: absolute;
    width: 400px;
    z-index: 14;
    padding-left: 80px;
    border-width:2px;
    border-color:#468847;
};

2 个答案:

答案 0 :(得分:0)

提醒框:

alert("text");

确认框:

if(confirm("text")==1)
{
//user pressed ok
}else
{
//user pressed cancel
}

你的意思是?

答案 1 :(得分:0)

如果您的条件得到满足,则显示div弹出

由于我没有剩下的代码,我已经为responseCode = 200指定了值来设置真正的cas Is this what you want

您的代码+使用jquery

添加弹出窗口的类
var responseCode=200;//&& data.length<= 1
if (responseCode == 200  ) {
         // infowindow_add.close();

   // $('#Mod').addClass( "modal" );
   document.getElementById('Mod').className += ' modal';     
      }

的CSS

@import url(http://fonts.googleapis.com/css?family=Open+Sans);
@import url(http://fonts.googleapis.com/css?family=Federo);

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    position: relative; /* needed for the overlay to extend when you scroll */
    /* general styles */
    padding: 30px;
    font-family: 'Open Sans', sans-serif;
    background: #f1c40f;
    color: #fff;
}

/* overlay styles, all needed */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 10;
}

/* just some content with arbitrary styles for explanation purposes */
.modal {
    width: 300px;
    height: 200px;
    line-height: 200px;
    position: fixed;
    top: 50%; 
    left: 50%;
    margin-top: -100px;
    margin-left: -150px;
    background-color: #f1c40f;
    border-radius: 5px;
    text-align: center;
    z-index: 11; /* 1px higher than the overlay layer */
}

.content {
    margin: 30px;
}

h1 {
    font-family: 'Federo', sans-serif;
}