#message
if message
h1.text-center.error-message #{message}
在Jade
中,我们使用上述内容显示条件error
消息
我们如何在html
中执行此操作?
答案 0 :(得分:0)
这个问题有点模糊,但我会试一试:
HTML
<div class="alert-container">
<center>Alert!</center><br /><hr /><br />
<div class="error">
</div>
</div>
CSS
div .alert-container {
background-color: #FFFFFF;
color: #040404;
font-family: Verdana;
font-size: 2em;
border-color: #000000;
border-radius: 25px;
text-align: center;
}
div .alert-container .hr {
color: #040404;
}
div .alert-container center {
font-size: 3.5em;
}
JavaScript(w / jQuery)
$(document).ready(function(){ $('.alert-container').css({visibility: hidden})});
// called on error
function error(text, set){
if (set){
$('.error').html(text + '<br /><button onclick="set(\'\', false);">OK</button>');
$('body').animate({opacity: '25%'}, 'fast');
$('.alert-container').css({visibility: visible});
} else {
$('body').animate({opacity: '100%'}, 'fast');
$('.alert-container').css({visibility: hidden});
}
}
免责声明:我肯定不是那里最好的程序员,我当然在某处有一些不好的代码。我希望这适合你!
另外,要实现jQuery,请将其添加到head
标记中:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.12.3.js" />