SO - 8712011

by Arun P Johny

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css">
<div class="parent">
    <span class="show" style="text-decoration: underline; cursor: pointer; color: blue">show</span>
</div>



<div class="demo" style="display: none">

<div id="dialog" title="Basic 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>

<!-- Sample page content to illustrate the layering of the dialog -->
<div class="hiddenInViewSource" style="padding:20px;">
<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p>
<form>
    <input value="text input"><br>
    <input type="checkbox">checkbox<br>
    <input type="radio">radio<br>
    <select>
        <option>select</option>
    </select><br><br>
    <textarea>textarea</textarea><br>
</form>
</div><!-- End sample page content -->

</div><!-- End demo -->

JavaScript

$("span.show").on("click", function(){
    $( "#dialog" ).dialog();
});

$("body").on("dialogclose", function(){
    alert("closed");
});