以下是我的代码。我想要的是每当提交表单以运行围绕一些定位和可见性移动的 3 条 jQuery 行。现在,每当我提交表单时,什么都没有发生。我哪里错了?
<!DOCTYPE html>
<html>
<head>
<title>Webther - What's it like out?</title>
<link rel="stylesheet" type="text/css" href="css/desktop.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function showResult(str)
{
if (str.length==0)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var response=xmlhttp.responseText;
if (response.length!=0)
{
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
}
}
}
xmlhttp.open("GET","livesearch.php?q="+str,true);
xmlhttp.send();
}
function ChangeVal()
{
document.getElementById("searchbox").value="";
}
</script>
</head>
<body>
<div id="pagecontainer">
<div id="indexlogocontainer">
<img id="indexlogo" src="images/fulllogo.png" />
</div>
<div id="indexsearchcontainer">
<div id="searchsurround"><form id="searchform"><input type="text" autocomplete="off" id="searchbox" name="q" size="50" value="Enter a city or zipcode here!" onkeyup="showResult(this.value)" onclick="ChangeVal()"/>
<input type="image" alt="Go!" src="images/goicon.jpg" id="searchsubmit" /></form></div>
<script type="text/javascript">
$("form").submit(function() {
$("#indexlogocontainer").animate({ marginTop: '-40px' }, 1000);
$("#mylocations").fadeOut("slow");
$("#forecast").fadeIn("slow");
return false;
});
</script>
<div id="livesearch"></div>
</div>
<div id="mylocations">
<h1>My Locations</h1>
<ul>
<li>BLAH</li>
<li>Blah!</li>
</ul>
</div>
<div id="forecast" style="display: none;">
PAGE INFO
</div>
</div>
</body>
</html>