我想做以下,
悬停时应选择日期。
如果在日历中选择了任何日期,则在悬停时我需要从病房的该元素应用一个类(“已选择”)。
我用下面的脚本做了这个功能。
$("#WBECalBodyNav a").hover(function (e) {
if ($("#WBECalBodyNav a.WBECheckIn").length != 0) {
//Step 1: Check for the current element Parent.
if ($(this).parent().attr("id") == "WBECalRightPane") {
//Step 2: Remove all selected classes before Checkin Class
$("#WBECalBodyNav").children().eq(1).find("a.WBESelected.WBECheckIn").prevAll().removeClass("WBESelected");
//Step 3: Find Checkin Class and remove Chekout class until current element.
$("#WBECalBodyNav").children().eq(1).find("a.WBESelected.WBECheckIn").nextUntil($(this)).removeClass("WBECheckOut");
//Step 4: Find Checkin Class and add Selected class until current element.
$("#WBECalBodyNav").children().eq(1).find("a.WBESelected.WBECheckIn").nextUntil($(this)).addClass("WBESelected");
//Step 5:Add Checkout Class for Current element
$(this).addClass("WBESelected WBECheckOut");
//Step 6: Remove Selected,Checkout Class for current element next all elements
$("#WBECalBodyNav").children().eq(1).find($(this)).nextAll().removeClass("WBESelected WBECheckOut");
////Step 7: Remove Checkout Class for current element next all elements
//$("#WBECalBodyNav").children().eq(0).find($(this)).nextAll().removeClass("WBECheckOut");
}
else {
//Step 2: Remove all selected classes before Checkin Class
$("#WBECalBodyNav").children().eq(0).find("a.WBESelected.WBECheckIn").prevAll().removeClass("WBESelected Chekout");
//Step 3: Find Checkin Class and remove Chekout class until current element.
$("#WBECalBodyNav").children().eq(0).find("a.WBESelected.WBECheckIn").nextUntil($(this)).removeClass("WBECheckOut");
//Step 4: Find Checkin Class and add Selected class until current element.
$("#WBECalBodyNav").children().eq(0).find("a.WBESelected.WBECheckIn").nextUntil($(this)).addClass("WBESelected");
//Step 5:Add Checkout Class for Current element
$(this).addClass("WBESelected WBECheckOut");
//Step 6: Remove Selected,Checkout Class for current element next all elements
$("#WBECalBodyNav").children().eq(0).find($(this)).nextAll().removeClass("WBESelected WBECheckOut");
//Step 7: Remove Checkout Class for current element next all elements
//$("#WBECalBodyNav").children().eq(0).find($(this)).nextAll().removeClass("WBECheckOut");
}
//Step 8: Return False
e.preventDefault();
}
});
它适用于单个 div 元素,但我希望这适用于总共 2 个 div 元素。
即,如果我在第一个 div 中选择任何日期,我应该能够在第二个 div 上继续我的选择。
但是,此当前脚本无法执行此功能。
请提供您的建议。