gpt4 book ai didi

javascript - 如何在元素的动态范围内添加类 - jQuery

转载 作者:行者123 更新时间:2023-11-28 15:22:39 25 4
gpt4 key购买 nike

我正在尝试使日期范围选择器类似于this .

我试过用类似的东西

     $('#calendar-dates').on('mouseover', 'td', function() {
if($(this).html() > window.start){
$(this).addClass("added");
}
});

$('#calendar-dates').on('click', 'td', function() {
window.start = $(this).html(); // get the number of the day

$(this).addClass("start"); // to mark it the date-selection start

});

我想要的是,如果我将鼠标按钮水平放在 this day 之后的 td 元素上,以突出显示它们一个 background-color

如果我vertically 改变前一行的background-color

我已经阅读了有关 slice 的内容,但我想不明白如何正确使用它。

同样使用 mouseover,在一个点之后停止突出显示元素。

请帮忙。

最佳答案

你可以试试这个。

$( "#calendar-dates" ).mouseover(function() {
// do something
}).click(function() {
// do something
});

关于javascript - 如何在元素的动态范围内添加类 - jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32166024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com