日期:2014-05-16 浏览次数:20618 次
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<style>
ul,li{
padding:0;
margin:0;
list-style:none;
}
li{
width:100px;
border:1px solid;
background:#FFF;
}
input[type=checkbox]{
visibility:hidden;
width:0;
}
span{
width:100%;
}
label{
display:block;
}
.selected{
background:#F60;
}
img{
width:20px;
height:20px;
}
</style>
<script>
$(function(){
$("input").change(function(){
var _this = $(this),
li = _this.closest("li");
if(_this.is(":checked")){
li.addClass("selected");
}else {
li.removeClass("selected");
}
});
});
function submit(){
var chkVal = [];
$("input[type=checkbox]:checked").each(function(){
chkVal.push(this.value);
});
alert(chkVal);
}
</script>
</head>
<body>
<div>