javascript - 如何更改警告框的样式?

标签 javascript css

我需要更改警告框中“确定”按钮的样式。

<head>
    <script type="text/javascript">
        function show_alert() {
            alert("Hello! I am an alert box!");
        }
    </script>
</head>
<body>
    <input type="button" onclick="show_alert()" value="Show alert box" />
</body>

最佳答案

警告框是一个系统对象,不受 CSS 约束。要执行此操作,您需要创建一个 HTML 元素并模仿 alert() 功能。 jQuery UI 对话为您做了很多工作,基本上如我所描述的那样工作:Link .

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#dialog" ).dialog();
  } );
  </script>
</head>
<body>
 
<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
 
 
</body>
</html>

关于javascript - 如何更改警告框的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7853130/

相关文章:

javascript - 如何以编程方式打开和关闭 Angular-UI 弹出窗口

javascript - 无法使用 Renderer2 更改使用 ViewChild 引用的按钮的属性

javascript - 将以秒为单位的时间间隔转换为更易读的形式

javascript - Chrome 扩展程序 : detecting keypresses in Google Docs

javascript - 在 native iPhone 应用程序的 UIWebView 中使用 InnerHTML 是否存在错误?

javascript - 在 JavaScript 中使用媒体查询或在 CSS 中使用 if/else 语句

javascript - 将鼠标悬停在 Chrome 上的 React 中数字输入的递增/递减值按钮上会导致持续增加

javascript - 使用 jQuery 自定义字母大小

android - 水平菜单浏览器兼容性

css - 如何拉伸(stretch)背景图像以填充 div