
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How can I change the styling of JavaScript alert button?
To change the styling of JavaScript alert button, use the custom alert box. You can try to run the following code to change the styling of alert buttons. The button looks different and more fancy −
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> </script> <script> function functionAlert(msg, myYes) { var confirmBox = $("#confirm"); confirmBox.find(".message").text(msg); confirmBox.find(".yes").unbind().click(function() { confirmBox.hide(); }); confirmBox.find(".yes").click(myYes); confirmBox.show(); } </script> <style> #confirm { display: none; background-color: #000000; color: #FCD116; border: 1px solid #aaa; position: fixed; width: 250px; left: 50%; margin-left: -100px; padding: 6px 8px 8px; box-sizing: border-box; text-align: center; } #confirm button { background-color: #FFFFFF; display: inline-block; border-radius: 12px; border: 4px solid #aaa; padding: 5px; text-align: center; width: 60px; cursor: pointer; } #confirm .message { text-align: left; } </style> </head> <body> <div id = "confirm"> <div class = "message">This is a warning message.</div> <button class = "yes">OK</button> </div> <input type="button" value="Click Me" onclick="functionAlert();" /> </body> </html>
- Related Articles
- How I can change the style of alert box using JavaScript?
- How I can change alert message text color using JavaScript?
- How to change button label in alert box using JavaScript?
- How I can show JavaScript alert box in the middle of the screen?
- How I can replace a JavaScript alert pop up with a fancy alert box?
- How I can set the width and height of a JavaScript alert box?
- How to change the color of the alert box in JavaScript?
- JavaScript how to get an alert to appear when I click on a button in a class?
- CSS Styling of File Upload Button with ::file-selector-button Selector
- JavaScript - Create an alert on clicking an HTML button
- How can I send radio button value in PHP using JavaScript?
- How can I show a euro or other HTML entity in JavaScript alert windows?
- How do I change button size in Python Tkinter?
- How to change the background color after clicking the button in JavaScript?
- How to add radio button list in alert dialog?

Advertisements