Div refresh and dialog link in that refresed div?

Div refresh and dialog link in that refresed div?

I'm not very good at English and olso not in JQuery, I'm more a phper.

I don't now if it's possible but i'm trying to make a monitor and i'm refreshing some content in a div element.
In that div i have a link/a to open a dialog. After the first refresh its not working anymore, to open the dialog.

Is it possible to do this or?

This is my test page:

  1. <!DOCTYPE html>
  2. <html>

  3. <head>

  4. <title>Monitor</title>
  5.     
  6. <meta charset="UTF-8" />
  7.     <!--<link rel="stylesheet" href="style.css" type="text/css" />-->
  8.     
  9.     <!-- Standaard JQuery -->
  10.     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

  11.     <!-- JQuery DIV refresh -->
  12. <script type="text/javascript"> 
  13. $(document).ready(function () {
  14.     setInterval( 
  15. function () { 
  16. $('#monitor').fadeOut("slow").html('<a id="btnok" href="#" title="Plaats of bewerk het bericht">Refresh link</a>').fadeIn("slow");
  17. }, 20000); // refresh every 30000 milliseconds 
  18. $.ajaxSetup({ cache: false });
  19.    });
  20. </script>
  21. <!-- JQuery UI -->
  22.     <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  23.     <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  24.     <script>
  25.     $(function() {
  26.       $( "#dialog" ).dialog({
  27.         autoOpen: false,
  28.         show: {
  29.           effect: "blind",
  30.           duration: 1000
  31.         },
  32.         hide: {
  33.           effect: "explode",
  34.           duration: 1000
  35.        }
  36.       });
  37.  
  38.       $( "#btnok" ).click(function() {
  39.       $( "#dialog" ).dialog( "open" );
  40.       });
  41.     });
  42.     </script>

  43. </head>
  44. <body>
  45. <div id="dialog" title="Basic dialog">
  46.   <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>
  47. </div>

  48. <div id="monitor"><a id="btnok" href="#" title=" ">Refresh link</a></div>

  49. <a id="btnok" href="#" title=" ">Normal link</a>

  50. </body>
  51. </html>