就是选中复选框后,点击按钮操作勾选框内容
解决方案 »
- 神奇的jquery错误,谁来说说看。
- extjs tabpanel提交数据时出现的一个问题
- 做一个却换鼠标放上去时触发xxk事件
- 头部调用的JS文件能否在页面显示完成后再加载?
- mysql+tomcat+myeclipse+ssh
- 请教关于frame的大小
- FireFox浏览器下如何用JS给hidd赋值?
- 为什么这个script在firefox运行出现错误,急,搞不好难休假
- 如何向html中控件写html语句
- 在javascript中,假如现在有一个form1,其中有一个下拉的列表框,列表框中有两项,现在如果我单击外面的一个按钮,如何使列表框(注意是下
- [前端-chrome]请问怎么通过console面板对页面进行一些交互
- ionic cli 5.2.3 中viewchild()使用问题报错
<!DOCTYPE html>
<html>
<head>
<title>wu</title>
</head>
<body>
<div>
<input type="checkbox" name="test" value="0" />0
<input type="checkbox" name="test" value="1" />1
<input type="checkbox" name="test" value="2" />2
<input type="checkbox" name="test" value="3" />3
<input type="checkbox" name="test" value="4" />4
<input type="checkbox" name="test" value="5" />5
<input type="checkbox" name="test" value="6" />6
<input type="checkbox" name="test" value="7" />7
<br>
<input type="button" id="btn" value="遍历" onclick="jqchk()" />
</div>
<script src="../js/jquery.min.js"></script>
<script type="text/javascript">
function jqchk() {
var chk_value = [];
$('input[name="test"]:checked').each(function () {
//在这里面操作复选框的值
chk_value.push($(this).val());
});
alert(chk_value.length == 0 ? '你还没有选择任何内容!' : chk_value);
}
</script>
</body>
</html>
<input class="btn btn-primary btn-sm" type="button" value="批量打回" onclick="chkClick()" disabled="disabled" />
function chkClick(){
var chk_value=[];
$('input[name="checkBox"]:checked').each(function(){
chk_value.push($(this).val());
if(chk_value.length==true){
document.getElementById("button1").disabled="";
}
});
if(chk_value.length==false){
document.getElementById("button1").disabled="disabled";
}
alert("点击!");
}
我这样点按钮还是点勾选框都会出现“点击”。怎么能让只有点按钮出啊?这个“点击”部分我是准备写操作勾选数据的代码的,谢谢大神
<input class="btn btn-primary btn-sm" type="button" value="批量打回" onclick="chkClick()" disabled="disabled" />
function chkClick(){
var chk_value=[];
$('input[name="checkBox"]:checked').each(function(){
chk_value.push($(this).val());
if(chk_value.length==true){
document.getElementById("button1").disabled="";
}
});
if(chk_value.length==false){
document.getElementById("button1").disabled="disabled";
}
alert("点击!");
}
我这样无论点按钮还是勾选框都会出现“点击”,怎么只让点按钮出现“点击”?