0
我對jQuery非常陌生,遇到了一些麻煩。我的項目使用表單登錄/註冊頁面,並且僅限於使用localStorage。當我運行該項目時,就好像登錄和註冊的提交按鈕被混淆了,儘管它們具有不同的id標籤。我很困惑,我知道這個問題可能非常愚蠢,但我一直在尋找幾個小時,無法修復它。任何幫助,將不勝感激!查詢混淆提交按鈕
的html代碼:
<!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 type="text/javascript" src="welcome.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>My Calendar</h1>
</div>
<div data-role="main" class="ui-content">
<a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-btn-b ui-corner-all">Sign-in</a>
<div data-role="popup" id="myPopup" class="ui-content" style="min-width:250px;">
<form method="post" action=" ">
<div class="ui-field-contain">
<label for="fullname">Full name:</label>
<input type="text" name="fullname" id="fullname">
<label for="email">E-mail:</label>
<input type="email" name="email" id="email" placeholder="Your email..">
</div>
<input id="submit" type="submit" data-inline="true" value="Submit">
</form>
</div>
</div>
<div data-role="main" class="ui-content">
<a href="#myPopup1" data-rel="popup" class="ui-btn ui-btn-inline ui-btn-b ui-corner-all">Sign-up</a>
<div data-role="popup" id="myPopup1" class="ui-content" style="min-width:250px;">
<form id="localStorageTest" method="post" action=" ">
<div class="ui-field-contain">
<label for="fullname">Full name:</label>
<input type="text" name="fullname" id="fullname" class = "stored">
<label for="email">E-mail:</label>
<input type="email" name="email" id="email" placeholder="Your email.." class = "stored">
</div>
<input id= "submitcheck" type="submit" data-inline="true" value="Submit">
</form>
</div>
</div>
</body>
</html>
的jQuery:
$(document).ready(function() {
if (localStorage["name"]&&localStorage["email"]) {
window.location.href = "calendar.html";}
else {$("<div>Incorrect Entry</div>").dialog();}
$('#localStorageTest').submitcheck(function() {
$('.stored').keyup(function() {
localStorage[$(this).attr('name')] = $(this).val();}
}); });
</script>
*「按鈕越來越糊塗」 *是不是一個合適的技術問題陳述,它告訴我們什麼值錢的東西。也不知道'submitcheck()'是什麼,因爲它不是一個jQuery核心方法 – charlietfl