javascript javascript警告框中显示粗体内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18508591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bold contents displayed in javascript alert box?
提问by Mohamed Thaufeeq
I wanna make bold content to be displayed in javascript alert box. as far I know I gave <b>
to make bold. but, it doesn't works. Is there anyway to make bold?
我想让粗体内容显示在 javascript 警报框中。据我所知,我给<b>
了大胆。但是,它不起作用。有没有办法大胆?
Code;
代码;
function f1()
{
alert("<b>Hello</b>")
}
采纳答案by daniel__
You can use Jquery UI Dialogfor that.
您可以为此使用Jquery UI 对话框。
Example:
例子:
$(function () {
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function () {
$(this).dialog("close");
}
}
});
});
Or a jquery plugin
或者一个jquery插件
Basically a pure alert box is a system object, and you can't apply CSS. However an alert box supports all Unicode characters and things like \n
and \t
基本上纯警报框是一个系统对象,您不能应用 CSS。但是,警报框支持所有 Unicode 字符以及诸如\n
和\t
回答by Jonathan Airey
Javascript's alert function does not support HTML tags. The alert function is strictly used for text output, not html or any other format.
Javascript 的警报功能不支持 HTML 标签。警报功能严格用于文本输出,而不是 html 或任何其他格式。
Please see https://developer.mozilla.org/en-US/docs/Web/API/window.alertfor more details.
请参阅https://developer.mozilla.org/en-US/docs/Web/API/window.alert了解更多详情。