The original is to determine those cells were selected, the results found not workable, only to judge the mouse down after those cells
The reason for this is that there are many interesting places in the case.
ONMOUSEOVER constant triggering, resulting in a lot of repeating elements
Because the event is bound to the entire table, there are also undefined
The repeated entry and exit of the mouse will result in intermittent repetition of the same elements,
How to solve them!
<table border= "1" id= "DNF" >
<tr>
<td rowspan= "2" >2</td>
<td>2</td >
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>4< /TD>
</tr>
Window.onload = function () {var flag = false;<br>//When mouse is pressed, true, release is true var indexs =[];<br>
The cell used to hold the mouse over is the position of the entire table, is initialized when the mouse is pressed, Dnf.onmousedown = function () {flag = true;
Indexs = []; Dnf.onmousemove = function (e) {if (flag)//If the mouse is pressed, the composite code {Indexs.push is executed (e.target,dnf.get
Elementsbytagname ("TD"))} Dnf.onmouseup = function () {flag = false;
Deleteundefined (); The null element Deleterepaint () is present because it passes through a border;//Because onmouseover does not trigger only once, and we choose to be able to iterate through one cell alert (INDEXS); function Deleterepaint () {for (Var j=0;j<indexs.length;j++)/Guaranteed The J element is unique {var head = Index
S[J]; for (var i=j+1;i<indexs.length;i++)//deletes and J duplicates {if (head = = Indexs[i]) {Indexs.spli
CE (i,1);
i--; function deleteundefined () {for (Var i=0;i<indexs.length;i++) {if ( typeof inDexs[i] = = "undefined") {Indexs.splice (i,1);
i--;
}} function Search (a,a) {var length = A.length;
for (Var i=0;i<length;i++) {if (a = = A[i]) {return i; {}}}} </script>
Above this original eco-JS, mouse down, after the simple example of those cells are small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.