摘要:jquery checkbox取值
<HTML>
<HEAD>
<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var cbxVehicle = new Array();
$("#clickAll").click(function() {
txt = "";
$('input:checkbox:checked[id="checkbox_id"]').each(function(i) { cbxVehicle[i] = this.value; });
txt = cbxVehicle.join(",");
//txt = "123";
$("#txt").attr("value",txt);
});
});
</script>
</HEAD>
<BODY>
<div id="myimg" >
<input type="checkbox" id="all" value="台北" >全選
<input type="checkbox" id="checkbox_id" value="台北" >台北
<input type="checkbox" id="checkbox_id" value="台中" >台中
<input type="checkbox" id="checkbox_id" value="高雄" >高雄<p>
</div>
<input type="text" id="txt" >
<p>
<button id="clickAll" >確定</button>
</BODY>
</HTML>