Tip: you can modify some code before running
Js function-Press Ctrl to select multiple table rows<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>New Document</title><meta name="title" content="" /><meta name="author" content="0xs.cn" /><meta name="subject" content="" /><meta name="language" content="zh-cn" /><meta name="keywords" content="" /><style type="text/css" >/* Default css rule */body {font: 12px "Verdana, ";}# myTable td {-moz-user-select: none;-webkit-user-select: none;} tr. select {background: # fcc ;}</style><script type="text/javascript" >// Shortcutfunction $ (s) {return typeof s = 'object '? S: document. getElementById (s);} // check start & end posfunction checkPos (el) {var oTable = $ ('mytable'); var startPos = oTable. startPos; if (startPos! = Null) {var endPos = el. rowIndex; if (endPos> startPos) {endPos ++;} else {endPos --;} loopRows (oTable, function (cur) {cur. className = ''; cur. childNodes [0]. childNodes [0]. checked = false ;}); // clearloopRows (oTable, function (cur) {cur. className = 'select'; cur. childNodes [0]. childNodes [0]. checked = true;}, startPos, endPos); oTable. startPos = null; return;} oTable. startPos = el. rowIndex; el. className = 'sele Ct ';} // check and select rowsfunction chkSelect (e) {var e = (e | event); var el = this; if (e. shiftKey) {checkPos (el);} if (e. ctrlKey) {el. className = (el. className = 'select '? '': 'Select'); el. childNodes [0]. childNodes [0]. checked = (el. className = 'select') ;}// get rows & do callbackfunction loopRows (oTable, callBack, start, end) {if (! OTable) {return;} callBack = callBack | function () {}; var trs = oTable. rows; var I = start | 0, l = end | trs. length; var flag = I <l; while (flag? I <l: I> l) {var cur = trs [I]; try {callBack (cur, I);} catch (e) {if (e = 'break') {break;} flag? I ++: I --;} // initfunction init () {var oTable = $ ('mytable'); loopRows (oTable, function (cur) {cur. onclick = chkSelect;}); oTable. startPos = null;} window. onload = init;</script></head><body><table cellpadding="0" cellspacing="0" border="1" onselectstart="return false;" width="100%" id="myTable"><script type="text/javascript">For (var I = 0; I <100; I ++) {document. write ('<tr><td><input type="checkbox" /></td><td>'+ I +'</td></tr>');}</script></table></body></html>
Tip: you can modify some code before running