8

I have simple html page:

<html>
<head>
<title></title>
</head>
<body>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {
            $("#OpenDialog").click(function () {
                $("#dialog").dialog({modal: true, height: 590, width: 1005 });
            });
        });
    </script>
    <a id="#OpenDialog" href="#">Click here to open dialog</a>
    <div id="dialog" title="Dialog Title">
        <p>test</p>
    </div>

</body>
</html>

I need to have popup content hidden and when click on the link open a dialog.

What I'm wrong with in my code?

Thanks!

ihorko
  • 6,029
  • 24
  • 71
  • 109

3 Answers3

29

id of element is not supposed to have # in it if you want to use jQuery selector as you used in $("#OpenDialog").click(

Change

<a id="#OpenDialog" href="#">Click here to open dialog</a>    

To

 <a id="OpenDialog" href="#">Click here to open dialog</a>
Adil
  • 139,325
  • 23
  • 196
  • 197
  • 4
    No good reason to downvote this one, Adil is correct. You don't put the # in the id of the actual markup, only when referencing it from a selector such as jQuery or CSS. In this case, the click handler is never assigned to the element "OpenDialog" because it doesn't actually exist. – mclark1129 Aug 10 '12 at 17:20
7

change the id of the link from #OpenDialog to OpenDialog

Raab
  • 31,764
  • 4
  • 47
  • 63
0

The css link and scripts need to go in the head, not the body.

And as others mentioned, also change the link id from #OpenDialog to OpenDialog.

Rachel
  • 1