2013-07-30 59 views
0

由於某些原因,我的Jquery在單擊此頁面中的第2步後將無法工作。 先去看看。 我說:Jquery - 使用Jquery表單驗證時未響應

<script type="text/javascript"> 
    $('li').click(function() { 
     $(this).slideUp(); 
    }); 
</script> 

而且它不會影響第二頁上的任何東西,它隻影響的第一頁。這裏是我到目前爲止的代碼:

<!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=utf-8" /> 
<title>Jquery Wizard</title> 
<link href="css/default.css" rel="stylesheet" type="text/css" /> 
<script src="js/jquery.js" type="text/javascript"></script> 
<script src="js/validate.min.js" type="text/javascript"></script> 
<script src="js/init.js" type="text/javascript"></script> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
<script type="text/javascript"> 
function loadnext(divout,divin){ 

$("." + divout).hide(); 
$("." + divin).fadeIn("fast"); 
} 



</script> 
</head> 
<body> 
<div id="wizardwrapper"> 

    <div class="1"> 

    <h3>Contact Info</h3> 
    <div id="wizardcontent"> 
<div class="wrapper"> 
Please Make Sure Our Records Are Correct: 
     <form id="form" class="blocks" action="#" method="post"> 
      <p> 
       <label>Name:</label> 
       <input type="text" class="text" name="name" /> 
      </p> 
      <p> 
       <label>Company:</label> 
       <input type="text" class="text" name="company" /> 
      </p> 
      <p> 
       <label>Your e-mail:</label> 
       <input type="text" class="text" name="email" /> 
      </p> 
      <p> 
       <label>Contact number:</label> 
       <input type="text" class="text" name="phone" /> 
      </p> 

      <p> 
       <label>&nbsp;</label> 

      </p> 
     </form> 
    </div> 

    </div> 
    <div class="buttons"> 
     <button type="submit" class="previous" disabled="disabled"> <img src="images/arrow_left.png" alt=""/> Back </button> 
     <button type="submit" class="next" onclick="loadnext(1,2);"> Next <img src="images/arrow_right.png" alt="" /> </button> 

    </div> 
    <ul id="mainNav" class="fiveStep"> 
     <li class="current"><a title=""><em>Step 1: User Info</em><span>Enter or Correct Contact Information</span></a></li> 
     <li><a title=""><em>Step 2: Subscription Management</em><span>Select your Subscription Settings</span></a></li> 

    </ul> 
    <div style="clear:both"></div> 
    </div> 

    <div id="wizardpanel" class="2"> 
    <h3>Step 2</h3> 
    <div id="wizardcontent"> 
    <script type="text/javascript"> 
     $('li').click(function() { 
     $(this).slideUp(); 
    }); 
     </script> 

    <div id="selection"> 
    <ul> 
    <li>asdf</li> 
    <li>asdf</li> 
    <li>asdf</li> 
    </ul> 

    </div> 


    </div> 

    <div class="buttons"> 
     <button type="submit" class="previous" onclick="loadnext(2,1);"> <img src="images/arrow_left.png" alt="" /> Back </button> 

     <button type="submit" class="next" onclick="submit()"> Finish <img src="images/arrow_right.png" alt="" /> </button> 
    </div> 
    <ul id="mainNav" class="fiveStep"> 
     <li class="lastDone"><a href="/" title=""><em>Step 1: User Info</em><span>Enter or Correct Contact Information</span></a></li> 

     <li class="current"><a title=""><em>Step 2: Subscription Management</em><span>Select your Subscription Settings</span></a></li> 

    </div> 


</div> 
</body> 
</html> 

回答

0

,必須用你的函數在

$(document).ready(function(){ 


}); 

的jQuery對初始加載工作(無功能())。

所以你的函數必須是:

$(document).ready(function(){ 
$('li').click(function() { 
$(this).slideUp(); 
}); 
}); 
+0

*拍打前額*感謝。看了100萬次之後,我開始模糊了這個問題。 – AlphaBravo

+0

大概應該提到jQuery包含兩次,並刪除第二個實例。 – Sparky