<html> |
<head> |
<title></title> |
<script src= "jquery-1.8.3.js" type= "text/javascript" ></script> |
<script> |
$(function(){ |
$( "input[name=names]" ).click(function(){ |
var name= $( "input[name=names]:checked" ); |
var arr= new Array(); |
name.each(function(key,value){ |
arr[key]=$( this ).val(); |
}); |
$( "#msgNames" ).text( "共选中" +arr.length+ "项:" +arr.join( "," )); |
|
}); |
}); |
</script> |
</head> |
<body> |
<input type= "checkbox" name= "names" value= "北京" />北京</br> |
<input type= "checkbox" name= "names" value= "上海" />上海</br> |
<input type= "checkbox" name= "names" value= "南京" />南京</br> |
<input type= "checkbox" name= "names" value= "重庆" />重庆</br> |
<input type= "checkbox" name= "names" value= "深圳" />深圳</br> |
<p id= "msgNames" ></p> |
</body> |
</html> |