简体   繁体   English

为什么我的jquery代码不运行?

[英]why my jquery codes doesn't run?

I want to toggle element that id's pg when click link. 我想在点击链接时切换id为pg的元素。 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>

close click function by adding }); 通过添加});关闭点击功能}); :

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

You're missing the final }); 你错过了最后的}); for the statement 声明

<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're using Firefox, check out Firebug . 此外,如果您使用的是Firefox,请查看Firebug Its an invaluable debugger tool and will show you where errors are happening. 它是一个非常宝贵的调试工具,可以向您显示错误发生的位置。

Chrome has a Developer Tools enabled, not sure about IE. Chrome启用了开发者工具,对IE不确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM