jquery的checkbox响应事件
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title></title>
<script type=”text/javascript” src=”js/jquery-1.2.6.min.js”></script>
<style type=”text/css”>
#testtable{ border-collapse:collapse;width:200px;table-layout:fixed;margin-top:20px;}
#testtable td{border:1px solid #ccc; height:20px;font-size:11px;}
</style>
</head>
<body>
<label>
<input type=”checkbox” value=”s1″ name=”checkbox0″ id=”checkbox0″ value=”checkbox” />s1
</label>
<label>
<input type=”checkbox” value=”s2″ name=”checkbox1″ id=”checkbox1″ value=”checkbox” />s2
</label>
<label>
<input type=”checkbox” value=”s3″ name=”checkbox2″ id=”checkbox2″ value=”checkbox” />s3
</label>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ id=”testtable”>
</table>
<script type=”text/javascript”>
$(document).ready(function(){
$(“input”).click(function(){
if(this.checked){
var _line=’<tr class=”‘+this.id+’tr”><td>’+this.value+’</td></tr>’;
$(“#testtable”).append(_line);
}else if(!this.checked){
var _c=(‘.’+this.id+’tr’);
$(“tr”).remove(_c);
}
});
});
</script>
</body>
</html>