Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why my jquery codes doesn't run?

I want to toggle element that id's pg when click link. header:

<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>

Elements:

<p id="pg">deneme deneme 123 deneme</p>
<a href="#" id="link">toggle</a>
like image 835
Birlikisgu Avatar asked Jun 16 '12 18:06

Birlikisgu


1 Answers

close click function by adding });:

$(function() {
     $("#link").click(function() {
         $("#pg").toggle();
     });
});
like image 165
mgraph Avatar answered Oct 26 '22 17:10

mgraph