由於我對JavaScript不太擅長,我在這段代碼中遇到了一些小問題。出於某種原因,我搞砸了語法,因爲我使用的是Visual Studio 2010,所以沒有真正的方法來調試JavaScript。我不確定我做錯了什麼,但是當我嘗試在瀏覽器中啓動這段代碼時,它似乎只是繼續加載,並沒有真正完成。我想知道我的表情是否有問題,但是無論如何,我已經在這方面做了很多工作,並且開始讓我感到沮喪。不允許頁面加載的JavaScript
任何答案將不勝感激。
var addAbsence = {
holDayCount: 0,
init: function() {
var deferrend = $.Deferred();
$("#addAbsence select[name=type]").change(function() {
switch ($(this).val()) {
case "0": case "1":
$("#addAbsence .borderWrap.type").animate({ "width": 266 }, 300, "swing", function() {
$("#addAbsence .borderWrap.tInfo").show();
});
$("#addAbsence .halfDays").show();
$("#addAbsence .lateArrivalTime").hide();
$("#addAbsence .paidHolidayCount").show();
break;
case "2":
$("#addAbsence .borderWrap.type").animate({ "width": 266 }, 300, "swing", function() {
$("#addAbsence .borderWrap.tInfo").show();
});
$("#addAbsence .halfDays").hide();
$("#addAbsence .paidHolidayCount").hide();
$("#addAbsence .lateArrivalTime").show();
break;
default:
$("#addAbsence .borderWrap.tInfo").hide();
$("#addAbsence .halfDays").hide();
$("#addAbsence .borderWrap.type").animate({ "width": 554 }, 300, "swing");
}
});
$("#addAbsence input.date").datepicker({
"dateFormat": "DD, d MM, yy",
onSelect: function() {
var dateFrom = Date.parse($("#addAbsence input[name=dateFrom]").val());
var dateTo = Date.parse($("#addAbsence input[name=dateTo]").val());
if (!isNaN(dateFrom) && !isNaN(dateTo)) {
var dates = addAbsence.getStartEndDate();
if ((dateFrom <= dateTo) &&
(dateFrom >= dates.dateFrom && dates.dateFrom <= dateTo) &&
(dateFrom <= dates.dateTo && dates.dateTo >= dateTo)) {
$("#addAbsence input[name=dateFrom], #addAbsence input[name=dateTo]").removeClass("error");
if ($("#addAbsence select[name=type]").val() == "0") {
addAbsence.calcDayCount();
$("#addAbsence p.holUsing").html(addAbsence.holDayCount);
}
else {
$("#addAbsence p.holUsing").html("0");
}
}
else {
$("#addAbsence input[name=dateFrom], #addAbsence input[name=dateTo]").addClass("error");
$("#addAbsence p.holUsing").html("--");
}
}
else {
$("#addAbsence input[name=dateFrom], #addAbsence input[name=dateTo]").removeClass("error");
}
}
});
$("#addAbsence .addHalfDay").click(function() {
addAbsence.calcDayCount();
if ($("#addAbsence input[name=dateFrom]").val().length > 0 && $("#addAbsence input[name=dateTo]").val().length > 0 &&
Date.parse($("#addAbsence input[name=dateFrom]").val()) <= Date.parse($("#addAbsence input[name=dateTo]").val())) {
$("#addAbsence input[name=dateFrom], #addAbsence input[name=dateTo]").removeClass("error");
if ($("#addAbsence tbody tr").size() < addAbsence.holDayCount) {
addAbsence.addHalfDay();
}
}
else {
$("#addAbsence input[name=dateFrom], #addAbsence input[name=dateTo]").addClass("error");
$("#addAbsence select[name=type]").change();
)};
$("form#addAbsence").submit(function() {
var boolDate = $(this).find("input[name=dateFrom]").dateRangeValid($(this).find("input[name=dateTo]"));
var boolComments = $(this).find("textarea[name=comments]").lengthValid(0, 350);
var boolAbsenceType = $(this).find("select[name=type]").selectValid(1);
)};
在firebug或Chrome開發工具中打開您的頁面/代碼,看看有哪些錯誤。如果你想在此之後獲得一些幫助,你想把所有的代碼放在http://jsfiddle.net/並在這裏分享,這樣人們就可以看一看現場實例。 –
事情是這樣的,它並沒有發現任何錯誤:( – kellehbeans