2015-11-15 41 views
-1

在我的代碼中一切正常,但jQuery不會影響代碼。我有ascss.css,我還擁有包括和所有這些工作的其他文件,但這個動畫(fadeIn)jQuery不運行

<head> 
<script src="jquery-1.11.1.min.js"></script> 
<script type="text/javascript"> 
$document.ready(function(){//this code does not run 
    $(".btn").submit(function(){ 
     $(".find").fadeIn(3000);   
     }); 

    }); 
</script> 
</head>  
<body> 
<form id="form1" name="form1" method="post" action="searchFile.php"> 
<table> 
    <tr><br> 
    <td >id :</td> 
    <td><input name="id" type="text" maxlength="40" /></td> 
    </tr> 
    <tr> 
    <td colspan="2" align="center"> 
    <input name="search" type="submit" value="search" class="btn"/></td> 
    </tr> 
</table> 
</form> 

<?php 
if(isset($_POST['id']) and !empty($_POST['id']) and strlen($_POST['id'])==10) 
{ 
    require_once("staticfileread.php"); 
    $s=staticfileread::search($_POST['id']); 
    echo "<br><br><div class='find'>$s</div>"; 
} 
?> 
</body> 
</html> 
+0

好,謝謝我做了什麼ü現在我應該怎麼做纔能有這個DIV的出現說suburition – naziye

回答

0
$document.ready(function() { 
// Should be: 
$(document).ready(function() { 

當被說;您可以縮短.ready功能到:

jQuery(function($) { 
    // Same as $(document).ready(function() {}); 
}); 

另外請注意,您正確要換:

$(".btn").submit(function() { ... 
// Buttons doesn't emit a submit event, but forms do: 
$("#form1").submit(function() { ... 
+0

你可以將'ready()'函數縮短爲'$(/ * code here * /);'https://api.jquery.com/ready/ –

+0

@Jonathan我知道,我只是在方法來確保'$'指的是'jQuery' – andlrc

1

第一:$document是未聲明的,所以你會扔引用錯誤。

$document.ready(someFunction)應該是$(document).ready(someFunction)或簡稱:$(someFunction)

第二次:提交事件消息表單未提交按鈕。

第三:即使事件處理程序被調用,表單完全可能會在您漸漸消失的內容出現之前完成提交和新的頁面加載。

四:你只是讓$(".find")在新頁面加載反正後,它似乎是在默認情況下可見,所以沒有什麼讓它從褪色。

+0

好的,謝謝我已經做了你現在說的話我應該怎麼做這個div出現在submition中 – naziye

0

有兩個問題與您的代碼:

  1. $document應該$(document)

  2. submit()聽衆只能綁定到<form>元素。它應該是$("#form1").submit()

0
在你的代碼jQuery代碼

需要開始像

$(document).ready(function() { 
    // need to write your code here 
}); 

檢查一次..