how to change the style of alert box

  1. Home
  2. javascript
  3. how to change the style of alert box

I need to change the style of the “OK” Button in an alert box.

<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>

First answer

The alert box is a system object, and not subject to CSS. To do this style of thing you would need to create an HTML element and mimic the alert() functionality. The jQuery UI Modal box does a lot of the work for you, working basically as I have described: Link.

Second answer

I use SweetAlert, It’s Awesome, You will get lots of customization option as well as all callbacks

Screenshot

swal("Here's a message!", "It's pretty, isn't it?");

enter image description here

Third answer

Not possible. If you want to customize the dialog’s visual appearance, you need to use a JS-based solution like jQuery.UI dialog.

Reprint:https://stackoverflow.com/questions/7853130/how-to-change-the-style-of-alert-box
Spread the love

Related articles

Comments are closed.