<table id="aa">
<tr>
<td><input type="checkbox" name="box" id="haha"/></td>
<td><input type="text" name="stuID1" id="stuID1"/></td>
</tr>
<tr>
<td><input type="checkbox" name="box" id="haha"/></td>
<td><input type="text" name="stuID2" id="stuID2"/></td>
</tr>
<tr>
<td><input type="checkbox" name="box" id="haha"/></td>
<td><input type="text" name="stuID3" id="stuID3"/></td>
</tr>
</table>
比如说还有一个提交按钮,当点击按钮时需要判断stuID(1-3)的value值是否为空,但是只有在那一行的复选框选中时才判断。如果复选框没有选中则不进行判断。求JS或者JQUERY详细代码
<tr>
<td><input type="checkbox" name="box" id="haha"/></td>
<td><input type="text" name="stuID1" id="stuID1"/></td>
</tr>
<tr>
<td><input type="checkbox" name="box" id="haha"/></td>
<td><input type="text" name="stuID2" id="stuID2"/></td>
</tr>
<tr>
<td><input type="checkbox" name="box" id="haha"/></td>
<td><input type="text" name="stuID3" id="stuID3"/></td>
</tr>
</table>
比如说还有一个提交按钮,当点击按钮时需要判断stuID(1-3)的value值是否为空,但是只有在那一行的复选框选中时才判断。如果复选框没有选中则不进行判断。求JS或者JQUERY详细代码
解决方案 »
- jquery问题
- 这段JS代码什么意思呢? 求教..
- jquery1.5的load方法不能使
- 描点失效的问题 大家来看看
- 这么让open()出来的窗口有滚动条?
- 图预加载,能把样式表的图片加载进来吗
- [顶有分]关于XMLHTTP 4.0以下版本的onreadystatechange只触发一次的问题。
- 高手请进,菜鸟碰到项目难题了:求根据XML生成动态的表格,表格的列是动态且嵌套,分不够再加的
- 为什么按提交三次才能真的提交一个
- javascript如何打印叶面上的指定区域?
- jQuery插件Ztree后台获得json格式对象数组后直接在前台页面显示为什么没有以树形结构显示?
- java web 实现浏览器窗口在任务栏变颜色和闪烁
function check() {
$("#aa tr").each(function () {
var tr = $(this);
var cb = tr.find(":checkbox[name='box']");
var tx = tr.find(":text:first");
if (cb.attr("checked") && $.trim(tx.val()).length == 0) {
//alert('');tx.focus();
return false;
}
});
return true;
}
var context= document.getElementById("aa");
var trs= context.getElementsByTagName("tr");
for(var i=0 ;i<trs.length ;i++){
var inputs= trs[i].getElementsByTagName("input");
alert("checkbox["+ i+"].checked=" + inputs[0].checked);
alert("text["+ i+"].value=" + inputs[1].value);
}
}
<script>
$(function () {
$("#btnTest").bind("click", function () {
$("input[type='checkbox']:checked").each(function () {
var obj = $(this);
var value = obj.parent("td").next().find("input").val();
if ($.trim(value).length == 0) {
alert("为空了");
}
});
});
})
</script>