You need to include jQuery and jQuery UI reference.
Then you need to create a container for your dialog, for example:
<div id="dialog"> <p> Your content here </p> </div>
Then you need to create a dialog, that is, when the DOM loads:
$(document).ready(function() { $("#dialog").dialog({ autoOpen: false, height: 200, width: 200 }); });
Then, to open the dialog with a button, you can add a simple HTML button and attach it via jQuery.
<input type="button" ID="btnDialog" value="Click here to open the dialog" />
Then attach to jQuery :
$("#btnDialog").click(function() { $("#dialog").dialog("open"); });
JS Fiddle: http://jsfiddle.net/VtZYD/
Make sure jQuery as well as jQuery UI loaded
This should be placed in your <head> section:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src=http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
You can also add CSS files using the link tag:
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
source share