English 中文(简体)
j 下表按行分列
原标题:jQuery next() td across table rows

我设计了一个使用html和j Query的习俗日历。 我想强调起算日期的连续数天(约2天)。 我的日历中的现有日期是可供使用的类别。 这部法典使用:

$(".monthly-calendar .available").hover(function() {
    $(this).toggleClass("selected");
    $(this).next(".available").toggleClass("selected");
}

不幸的是,下()只为母行工作。 这在一行最后一栏中一栏中就产生了问题,在这种情况下,一栏只突出一栏。 我如何在接下来的几行中超负荷选择现有的TD公司?

The fiddle is available on http://jsfiddle.net/yL573/1/。 第26条对问题进行跟踪。 26年的更替也应突出27个或下一个可用数字。 我想概括一下这几天(k>1,此处为k=2)的选择。

最佳回答

could it be something like this? i made a quick jsfiddle for your concept

甚至在中间几天已经不存在(没有现成的班级)的情况下,它甚至在不同行各业。

http://jsfiddle.net/dP3Bk/1/"rel=“nofollow> http://jsfiddle.net/dP3Bk/1/

让我知道,这是你期望它做些什么。

最终不采用<代码>.next(),而是使用所有<代码><td>要素阵列中的元件索引。

javascript:

$( #tableid td.available ).hover(function(){
    // mouse in
    var available = $( #tableid td.available );
    var i = available.index($(this));
    $(available[i]).add($(available[i+1])).addClass( current );
}, function(){
    // mouse out
    $( td.current ).removeClass( current );
});

remark if you have a lot of elements this can be a performance hit. in any case, i d add the id of the table in front of your selectors, not to work with all td.available elements.

问题回答

humble suggestion... check if the element is the (n-1)th child of the row or even the nth child ...if thats the case highlight the nth and the first child of the next row for n-1 and first and second td of next row for nth element... example in a row of 10 cols our element is 9th then 10th and the next rows 1st columns to be set with the selected class.... if the element is 10th check for the last child and select the parent trs next and then its 1st two child td....a conditional should suffice i guess... hope i made sense .....cheers!!





相关问题
Java Checking number months

I think I figure out what question I am trying to ask I dont want get(Calendar.MONTH) I want the month not to be greater than the last caldendar month that is why i am doing month -1, i realize that ...

How to show custom events to a Kronolith calendar

I want to show events from an external source in the Kronolith calendar views. I don t want to do this by exporting the events to iCal and then showing them as an external calendar. The events are ...

How to reset a field when changing a date ui.datepicker.js

I m using ui.datepicker.js I have a form and when the date is changed I want that another field reset the status (this field is a dropdown select box). The case is the following: The user enter the ...

Calendar returns wrong month [duplicate]

Calendar rightNow = Calendar.getInstance(); String month = String.valueOf(rightNow.get(Calendar.MONTH)); After the execution of the above snippet, month gets a value of 10 instead of 11. How come?

How to determine if date/time is EDT or EST in Java?

I have a PDF that users must complete. The PDF has date and time fields on it. The PDF instructs the users to input the date and time in Eastern format (Not EST or EDT). When the user completes the ...

热门标签