我在 jQuery UI 的主题页面上看到了这些,并认为它们很简洁。
我想知道如何以静态方式和 JavaScript 来显示这些样式的消息。
提前致谢。
最佳答案
使用 Chrome 开发者工具,我检查了错误消息的 HTML。您可以对另一个执行相同的操作,或者您可以查看 jQuery UI CSS Framework .
HTML
<div class="ui-widget">
<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
<p>
<span class="ui-icon ui-icon-alert"
style="float: left; margin-right: .3em;"></span>
<strong>Alert:</strong> Sample ui-state-error style.
</p>
</div>
</div>
CSS
body {
font-family: Verdana,Arial,sans-serif;
font-size: 10px;
}
p {
margin: 1em 0;
}
strong {
font-weight: 900;
}
您可以使用addClass
方法使用 JS 以编程方式添加这些类。另请参阅show
和 hide
您可以使用这些方法来显示/隐藏这些消息。
<button id="show">Show</button>
<button id="hide">Hide</button>
$("#show").click(function() {
$(".ui-widget").show();
});
$("#hide").click(function() {
$(".ui-widget").hide();
});
参见fiddle .
关于jquery - 使用 jQuery UI 显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5267569/