see fiddle

我有html表和一个文本框和一个button。通过拖动单元格进行单元格选择。单击按钮时我正在获取文本框的值并将其放入单元格的span标签。我必须取消点击分钟单元格0、15、30、45。在小提琴中,您看到当我单击分钟单元格时,它使CSS变为绿色,并且CSS长度增加了(警报中那些令人窒息的)。

最佳答案

这是你想要的吗 ?

-编辑-

现在,您只能以直线方式(向上或向下)突出显示。
可能有一种更优雅的方式来完成所有这些操作,但我认为这会如您所愿

演示:http://jsfiddle.net/vrW2n/9/

// Add this variable
var lastRow = 0;


mousedown()中:

    // This line gets the index of the first clicked row.
    lastRow = $(this).closest("tr")[0].rowIndex;

    active = true;
    $(".csstdhighlight").removeClass("csstdhighlight"); // clear previous selection

    //This is the big trick
    $(".temp_selected").removeClass("temp_selected");
...


mousemove()中:

...
    /* Begin my edit
    Compares the actual 'mousemove' row index
    with the last and next row index
    */
    var thisRow = $(this).closest("tr")[0].rowIndex;

    if( lastRow == thisRow || lastRow == thisRow - 1 || lastRow == thisRow + 1 ){
        lastRow = $(this).closest("tr")[0].rowIndex;
    }else
        return;
    // End my edit
...

关于jquery - 禁用点击分钟单元格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10998126/

10-12 16:24
查看更多