jquery没有在特定的html文件上工作

Bab*_*uro 1 html jquery

我是jquery的新手,并且遇到了一个奇怪的问题.不知怎的,jquery不能处理我作为网站首页创建的html文件.如果我在一个空白的html文件中使用它,同样的jquery-code正在工作,所以我或者它正在尝试使用的服务器(000webhost.com)应该没有任何问题.

我一直在努力调试这几天,所以任何帮助都会受到赞赏.

这是我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>MG</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
jQuery.noConflict();
jQuery(document).ready(function($){
    $("button").click(function(){
      $("#logo").hide();
    });
});
</script>
</head>
<body>
<div id="content">
    <div id="header">
        <div id="logo"><button>test</button></div>
        <div id="sitehistory"> History:<br />Samu added [PIC] (30min ago)</div>
    </div>

    <div id="container">
        <div id="wall">
            <div id="navi"><a id="showlatest" title="Latest">Latest</a> | <a id="showmostpopular" title="MostPopular">Most Popular</a> | <a id="showsearchbox" title="Search">Search</a> </div>
            <?php include("latest.php");?>
        </div>
        <div id="profilebar"><?php include("login-form.php"); ?></div>
        </div>
    <div id="footer">
        <a href="index.html" class="lefty">Home</a>|
        <a href="index.html" class="lefty">Profile</a>|
        <a href="index.html" class="lefty">FAQ</a>|
        <a href="index.html" class="lefty">Contact</a>
    </div>
</div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Sco*_*own 6

你需要一个

<script type="text/javascript">

之前

jQuery.noConflict();
jQuery(document).ready(function($){
    $("button").click(function(){
      $("#logo").hide();
    });
});
</script>
Run Code Online (Sandbox Code Playgroud)

  • 还要确保关闭jquery的脚本标记:<script type ="text/javascript"src ="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js "> </ script>然后启动另一个脚本块. (2认同)