Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

I want to change the style of “OK” button in the alert box. How can I do it?

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

1 Answer

0 votes
by (13.1k points)

To change the style you have to create an HTML element and mimic the alert() functionality. The jQuery UI Dialogue does a lot of the work for you.

Here is the example:
 

<!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="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>

Want to be a Full Stack Developer? Check out the Full Stack Developer course from Intellipaat.

Related questions

0 votes
1 answer
asked Apr 10, 2021 in Web Technology by Jake (7k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked May 15, 2021 in Java by sheela_singh (9.5k points)

Browse Categories

...