I seem to have this working except for the fact that once the link is clicked, the datepicker opens, then I select a date and all is good and well, then once I try to click the link again, the date picker does not open again.

What am I doing wrong?

```
<html>

<head>

<!-- LOAD JQUERY LIBRARY: -->  
    <link   href="jq/jquery-ui.css"         type="text/css" rel="stylesheet" />
    <script src="jq/jquery.min.js"          type="text/javascript"> </script>
    <script src="jq/jquery-ui.min.js"       type="text/javascript"> </script>

<script type="text/javascript">

function test() { 

var datePickerValue = null; 

$("#d1").datepicker().datepicker("show").change(function () 
{ 
    $('#d1').datepicker({onSelect:  datePickerValue = $(this).val() }).hide();

  alert("You picked: " + datePickerValue);
}); 

} 

</script>

</head>

<body>

<div id="d1"></div>
<a href="javascript:test()">test</a>

</body>

</html>

```