양식이있는 PHP 파일이 있습니다. 양식 작업은 다른 PHP 파일입니다. 양식을 제출하면 다음 페이지 (양식 작업 페이지)의 Jquery가 작동하지 않습니다. 그러나 폼 액션이 아닌 나 자신이 페이지를 열면 Jquery가 완벽하게 작동합니다. 첫 페이지에Jquery 스크립트가 양식을 보내는 페이지에서 작동하지 않습니다
코드 :
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="getsnacks.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header" id="status">
<h1>Snacks Bestellen</h1>
</div>
<div data-role="main" class="ui-content">
<fieldset class="ui-field-contain" id="snack1">
<span id="snack1optie1">
<select name="optie1" id="optie1" class="optie1">
</select>
</span>
<span id="snack1optie2">
<select name="optie2" id="optie2" class="optie2">
</select>
</span>
<span id="snack1optie3">
<select name="optie3" id="optie3" class="optie3">
</select>
</span>
</fieldset>
</div>
</div>
</body>
</html>
JQuery와 페이지 (단지 시험)에 :
$(document).ready(function() {
$('#snack1optie2').hide();
$('#snack1optie3').hide();
$('#snack1optie1').click(function(){
$('#snack1optie2').show();
});
$('#snack1optie2').click(function(){
$('#snack1optie3').show();
});
$('#snack1optie3').click(function(){
$('#snack1optie3').hide();
});
});
감사의 evaluatelogin.php 페이지
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="login.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header" id="status">
<h1>Snacks Bestellen</h1>
</div>
<div data-role="main" class="ui-content">
<form method="post" action="evaluatelogin.php">
<label for="company">Bedrijfsnummer:</label>
<input type="text" name="company" id="company">
<fieldset class="ui-field-contain" id="fieldset_user">
<label for="user">Gebruiker:</label>
<select name="user" id="user">
</select>
</fieldset>
<input type="submit" value="Volgende" data-icon="user" data-iconpos="right" data-inline="true">
</form>
</div>
</div>
</body>
</html>
코드 사전,
어디 당신은 당신의 jQuery 코드를 배치 할? –
HEAD의 getsnacks.js 파일에 있습니다. –
$ (document) .ready 외부에 코드를 작성해보십시오. –