weixin_33737134 2017-09-13 18:54 采纳率: 0%
浏览 1243

jQuery中的Hide()不起作用

Code in index.html

<head>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</head>

<body onload="loadIndex()">
<a id="registration" href="register.html"> Register </a>
</body>

Code in index.js

function loadIndex() {
alert("Page is loaded");
$("#registration").hide();
}

I get alert, but link is not hidden. I have more files, and this does not work in any of them. I think that mistake is not in code, but I don't know where is.

  • 写回答

3条回答 默认 最新

  • ?Briella 2017-09-13 18:58
    关注

    Your code is fine with the exception of a tiny syntax issue. You're just missing the closing tag </head>. Check code below:

    function loadIndex() {
      alert("Page is loaded");
      $("#registration").hide();
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <head>
      <script type="text/javascript" src="js/jquery.min.js"></script>
      <script type="text/javascript" src="js/index.js"></script>
    </head>
    
    <body onload="loadIndex()">
      <a id="registration" href="register.html"> Register </a>
    </body>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料