<form method="post" id="fm" action="">
<input type="checkbox" />
<input type="checkbox" />
</form>
<div><div>2</div>1</div>
<script type="text/javascript">
<!--
var Break = function (sentinel, F) {
return function () {
try {
F();
} catch (exp) {
if (exp.message != sentinel) throw exp;
}
};
};
var each = function (nodes, callback, endcallback) {
var array = [], l = nodes.length, i = 0;
Break('break', function () {
for (; i < l ; i ++) callback(nodes[i], i, array);
endcallback && endcallback();
})();
return array;
};
Break("exit", function(){
each(document.getElementById("fm").elements, function(chk){
if(chk.checked){
throw new Error("break");
}
}, function(){
alert("至少选择1个");
throw new Error("exit");
});
alert("success exit");
})();
//-->
</script>
posted on 2008-12-17 16:32
汪杰 阅读(166)
评论(0) 编辑 收藏 引用 所属分类:
javascript