日期:2014-05-16 浏览次数:20352 次
<style type="text/css">
td{
width :50px;
height:50px;
text-align: center;
cursor: pointer;
}
#preview , #result{
width :200px;
height :100px;
border: 1px solid;
}
</style>
Preview
<div id="preview"></div>
Result
<div id="result"></div>
<table border="1">
<tr>
<td onclick="fn(1)">1</td>
<td onclick="fn(2)">2,A,B,C</td>
<td onclick="fn(3)">3,D,E,F</td>
</tr>
<tr>
<td onclick="fn(4)">4,G,H,I</td>
<td onclick="fn(5)">5,J,K,L</td>
<td onclick="fn(6)">6,M,N,O</td>
</tr>
<tr>
<td onclick="fn(7)">7,P,Q,R,S</td>
<td onclick="fn(8)">8,T,U,V</td>
<td onclick="fn(9)">9,W,X,Y,Z</td>
</tr>
</table>
<script type="text/javascript">
var data = [
[],
[1],
[2,'A','B','C'],
[3,'D','E','F'],
[4,'G','H','I'],
[5,'J','K','L'],
[6,'M','N','O'],
[7,'P','Q','R','S'],
[8,'T','U','V'],
[9,'W','X','Y','Z']
];
var click_info = {} , prevIndex = -1 , isFirst = true;
function fn(_index){
if(prevIndex!=_index && !isFirst){
click_info[prevIndex].clicks = 0;
clearTimeout(click_info[prevIndex].clock);
}
prevIndex = _index;
isFirst = false;
if(click_info.hasOwnProperty(_index)){
++click_info[_index].clicks;
clearTimeout(click_info[_index].clock);
}else{
click_info