前男友订婚后并不快乐,我很难过,我不想写任何东西。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
.inputs{
width: 500px;
height: 500px;
border: 1px solid #333;
background-color: #FF9800;
margin: 2% auto;
}
.inputs input{
width: 30px;
height: 30px;
}
.inputs input:after{
}
.btn{
color: #fff;
border: 1px solid #fff;
margin: 5% auto;
background-color: #ff9800;
}
</style>
<script type="text/javascript">
$().ready(function() {
var $giveID = $("#giveID");
$giveID.click(function(){
var storesID = [];
var ids = document.getElementsByName("ids");
var flag = false ;//标记判断是否选中一个
for(var i=0;i<ids.length;i++){
if(ids[i].checked){
flag = true;
storesID.push(ids[i].value); //如果有id,可以把value改成id
console.log(storesID);
}
}
if(!flag){
alert("请最少选择一项!");
return false ;
}
})
});
</script>
</head>
<body>
<div class="inputs">
<input type="checkbox" name="ids" value="1">
<input type="checkbox" name="ids" value="2">
<input type="checkbox" name="ids" value="3">
<input type="checkbox" name="ids" value="4">
<input type="checkbox" name="ids" value="5">
<input type="checkbox" name="ids" value="6">
<input type="checkbox" name="ids" value="7">
<input type="checkbox" name="ids" value="8">
<input type="checkbox" name="ids" value="9">
<input type="checkbox" name="ids" value="10">
<input type="checkbox" name="ids" value="11">
<input type="checkbox" name="ids" value="12">
<button id="giveID" class="btn">选中后点击我</button>
</div>
</body>
</html>