Why are my jquery codes not starting?

I want to switch the item to id pg when the link is clicked. heading:

<title>Example</title>
        <script type="text/javascript" src="jquery-1.3.2.js"></script>
        <script type="text/javascript">
            $(function() {
                $("#link").click(function() {
                    $("#pg").toggle();
            });
        </script>

Items

<p id="pg">deneme deneme 123 deneme</p>
<a href="#" id="link">toggle</a>
+5
source share
2 answers

You are missing the final });for the operator

<title>Example</title>
  <script type="text/javascript" src="jquery-1.3.2.js"></script>
  <script type="text/javascript">
    $(function() {
      $("#link").click(function() {
        $("#pg").toggle();
      });
    )}; //<-- Missing close bracket
  </script>

Also, if you are using Firefox, check out Firebug . This is an invaluable debugger tool and will show you where errors occur.

Chrome has developer tools, but are not sure about IE.

+6
source

close the click function by adding });:

$(function() {
     $("#link").click(function() {
         $("#pg").toggle();
     });
});
+10
source

All Articles