Highlighting table cells for a single row on mouse drag

别来无恙 提交于 2019-12-05 18:21:37

Taking the example that is in the other question, you should give the "td" element an attribute, like data-row and data-col, then when somebody is selecting store the current data-col and prevent that the user can select other columns with diferent data-col value.

I put a working code in the following link, you can change it to only works with the rows.

Working example

You need to use the getAttribute method:

element.getAttribute("data-col")

When you highlight the first one, set a boolean, like isHighlighted = true; Then in your actual highlighting just do

if(isHighlighted == false){
    ///do highlighting
}

WHen you deselect the first box simply set the boolean to false.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!