how to create Alert Dialog Box With jQuery

in #utopian-io7 years ago (edited)

What Will I Learn?

  • you will learn about how to creating an alert dialog box with jQuery

Requirements

  • Xampp and web browser
  • Codeigniter Library
  • understand plugins jQuery Alert

Difficulty

  • Intermediate

IMPLEMENTATION

with a jQuery plugin we can create a dialog box that looks the same in all browsers and can certainly be customized according to our taste through css file. The name of the plugin is jQuery Alert, its file size is only 7kb. Examples of its use, as below :

<script type="text/javascript" src="jquery.alerts.js"></script>
<script type="text/javascript">

        $(document).ready( function() {

            $("a#alert_button").click( function() {
                jAlert('Displays alert dialog box containing warning.', 'Alert Dialog Box');
            });

            $("a#confirm_button").click( function() {
                jConfirm('Do you want to delete this data?', 'Confirmation Dialog Box', function(r) {
                    if( r ) jAlert('Data successfully deleted', 'Confirmation Dialog Box Results | True')
                    else jAlert('The data is not deleted.', 'Confirmation Dialog Box Results | False');
                });
            });

            $("a#prompt_button").click( function() {
                jPrompt('Type a word in the textbox below :', 'Enter a word....', 'Prompt Dialog Box', function(r) {
                    if( r ) jAlert('The word you entered : <b>' + r + '</b>', 'Dialog Box Results');
                });
            });

        });

</script>

It's just a function to call its jQuery Alert plugin only, and to call it via a link, can use html syntax as below :

<p><a href="#" id="alert_button">Alert Dialog</a></p>
<br />
<p><a href="#" id="confirm_button">Confirm Dialog</a></p>
<br />
<p><a href="#" id="prompt_button">Prompt Dialog</a> </p>
</div>

the result is like this :

1.PNG

if the alert box is clicked it will display a dialog box like this

2.PNG

if the confirm box is in click it will display a dialog box like this
3.PNG

4.PNG

And last stage, if the Prompt box is clicked it will display a dialog box like this

5.PNG

6.PNG

Hopefully this article can help all programmer friends. Thank you for reading this article.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • Simple and easy to find tutorial on the internet on this subject.

Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Coin Marketplace

STEEM 0.15
TRX 0.16
JST 0.028
BTC 67807.24
ETH 2423.65
USDT 1.00
SBD 2.33