當談到使用jQuery時,我是一個絕對的新手。我編寫代碼並在Dreamweaver中進行測試。它完美的工作,直到我試圖在瀏覽器中運行它。 jQuery的目標是隱藏<div>
,將文本追加到另一個<div>
並顯示<div>
。我將所有編碼放在一個名爲scripts.js的文件中。jQuery在Dreamweaver中正常工作,但不在任何瀏覽器中。怎麼修?
這個文件的內容是
$(document).ready(function() { //SignIn validation + content change
$("#enter_email").hide();
$("#enter_password").hide();
$("#main2").hide();
$("#signIn").click(function(event){
var email = $("#Email").val();
var password = $("#password").val();
if(email == "" && password == "")
$("#enter_email").show().add("#enter_password").show();
else if(email != "" && password == "")
$("#enter_password").show();
else if(email == "" && password != "")
$("#enter_email").show();
else if(email == "admin" && password == "password")
$("#login").hide().add("#register").hide().add("#displayUserName").text(', ' + email).add("#main2").show().remove("#register");
else
(overlay());
});
var now = new Date();
var hours = now.getHours();
var msg;
if(hours<12)
msg = "Good Morning";
else if(hours<18)
msg = "Good Afternoon";
else
msg = "Good Evening";
$('#greeting').text(msg);
//Control the look of selected catalog categories
$(".shop-links1").click(function(){//Add category to selected
$(".clear").show();
$("#selected").show();
$("#catalogNav1").hide();
$('div[class="shop-links1"]').add("#selected ul").append("<li><a class='selectedLinks' href=''>Category: " + $(this).text() + " </a></li>"); });
$(".shop-links2").click(function(){//Add price to selected
$(".clear").show();
$("#selected").show();
$("#catalogNav2").hide();
$('div[class="shop-links2"]').add("#selected ul").append("<li><a class='selectedLinks' href=''>Price: " + $(this).text() + " </a></li>");
});
$(".shop-links3").click(function(){//Add size to selected
$(".clear").show();
$("#selected").show();
$("#catalogNav3").hide();
$('div[class="shop-links3"]').add("#selected ul").append("<li><a class='selectedLinks' href=''>Size: " + $(this).text() + " </a></li>");
});
$(".shop-links4").click(function(){//Add artist to selected
$(".clear").show();
$("#selected").show();
$("#catalogNav4").hide();
$('div[class="shop-links4"]').add("#selected ul").append("<li><a class='selectedLinks' href=''>Artist: " + $(this).text() + "</a></li>");
});
$(".clear").click(function(){
$(".clear").hide();
$("#selected ul li:not(:first)").remove();
$("#selected").hide();
$("#catalogNav1").show();
$("#catalogNav2").show();
$("#catalogNav3").show();
$("#catalogNav4").show();
});
//Sort catalog
$("#tops").click(function(){//Sort by tops
$(".tops").show();
$(".tunics").hide();
$(".dresses").hide();
});
$("#tunics").click(function(){//Sort by tunics
$(".tops").hide();
$(".tunics").show();
$(".dresses").hide();
});
$("#dresses").click(function(){//Sort by dresses
$(".tops").hide();
$(".tunics").hide();
$(".dresses").show();
});
});//End document.ready
註釋下的面積「//控制選擇目錄類別的樣子」是我用來做什麼。
的HTML頭
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/scripts.js"></script>
<!-- Unique title on each page to increase search engine optimisation. Should always contain accurate information as well as some of the main focus areas. -->
<title>Art on Fashion</title>
<!-- Page description meta tag gives search engines a summary of what the page is about -->
<meta name="description" content="This site has been created and submitted in partial fulfilment of the BSc Hons Information and Communication Technologies course, it is a final year project that focuses on XHTML, PHP, JavaScript, SEO, MySQL, CSS and a Content Management System"/>
<link href="css/styles.css" rel="stylesheet" type="text/css" media="screen" />
</head>
你能從你的HTML文件中添加'
'標籤的內容嗎? – Fresheyeball 2013-02-21 17:04:03您是否嘗試過使用瀏覽器的控制檯進行調試,以查看正在生成的錯誤消息?你記得包括jQuery和檢查你的路徑? – j08691 2013-02-21 17:06:52
http://scmweb.infj.ulst.ac.uk/~B00448232/com601/assignment_1/login.html – 2013-02-21 17:09:48