http://blog.csdn.net/ailinty/article/details/7339489 if (p.checkbox) { $('div:eq('+n+')',g.cDrag).css({'left':cdpos+22+'px'}).show(); } else{ $('div:eq('+n+')',g.cDrag).css({'left':cdpos+'px'}).show(); } if (p.checkbox) { var cth = $(''); var cthch = $(''); var objTr = $(tr); cthch.addClass("noborder").click(function(){ if(this.checked){ objTr.addClass('trSelected');} else{ objTr.removeClass('trSelected'); } }) cth.addClass("cth").attr({ width: "19"}).append(cthch); $(tr).prepend(cth); } if(p.checkbox){ if($(this).hasClass('trSelected')){ $(this).find('input')[0].checked=true; }else{ $(this).find('input')[0].checked=false } } if (p.checkbox) { $('tr', g.hDiv).each( function () { var cth = $(''); var cthch = $(''); cthch.click(function () { if (this.checked) { $('tbody tr', g.bDiv).each(function () { $(this).addClass('trSelected').find('input')[0].checked = true; }) } else { $('tbody tr', g.bDiv).each(function () { $(this).removeClass('trSelected').find('input')[0].checked = false; }) } }) cth.addClass("cth").attr({ width: "22" }).append(cthch); $(this).prepend(cth); }) };