Jack Marquies Jack Marquies - 1 year ago 141
Javascript Question

Creating modal dialog with jquery

When someone clicks my label, i want to open a small "Alert" like element, and i want to be able to use the modal's buttons functionality.

Is there a jquery library / extension that can easily do something like this?

$(document).on('click', '#MyLabel', function() {



Answer Source

This a fundamentally simple task in jQuery UI. See jsfiddle

    autoOpen  : false,
    modal     : true,
    title     : "A Dialog Box",
    buttons   : {
              'OK' : function() {
                  var textValue = $('#myTextBox').val();
                  alert('The value of the text box is ' + textValue);
                  //Now you have the value of the textbox, you can do something with it, maybe an AJAX call to your server!
              'Close' : function() {
                  alert('The Close button was clicked');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download