[javascript]代码库
onclick="javascript:checknode(this);"
function checknode(obj)
{
var chk = $("input[type='checkbox']");
var count = chk.length;
var num = chk.index(obj);
var level_top = level_bottom = chk.eq(num).attr('level')
for (var i=num; i>=0; i--)
{
var le = chk.eq(i).attr('level');
if(eval(le) < eval(level_top))
{
chk.eq(i).attr("checked",'checked');
var level_top = level_top-1;
}
}
for (var j=num+1; j<count; j++)
{
var le = chk.eq(j).attr('level');
if(chk.eq(num).attr("checked")=='checked') {
if(eval(le) > eval(level_bottom)) chk.eq(j).attr("checked",'checked');
else if(eval(le) == eval(level_bottom)) break;
}
else {
if(eval(le) > eval(level_bottom)) chk.eq(j).attr("checked",false);
else if(eval(le) == eval(level_bottom)) break;
}
}
}
[代码运行效果截图]