JavaScript:选中复选框并单击按钮时隐藏所有网格行
对于下面的代码,我需要您的专业知识JavaScript:选中复选框并单击按钮时隐藏所有网格行,javascript,onclick,hide,tr,Javascript,Onclick,Hide,Tr,对于下面的代码,我需要您的专业知识 <html> <head> <script> function delrow() { document.getElementById("db_grid_row1").style.display = 'none'; document.getElementById("db_grid_row2").style.display = 'none'; document
<html>
<head>
<script>
function delrow() {
document.getElementById("db_grid_row1").style.display = 'none';
document.getElementById("db_grid_row2").style.display = 'none';
document.getElementById("db_grid_row3").style.display = 'none';
document.getElementById("db_grid_row4").style.display = 'none';
}
</script>
</head>
<body>
<form action="rowhide_action.php" method="post" name="save_form">
<input type="button" value="Delete" onClick="delrow();"></input>
<table border="1">
<thead>
<tr>
<th>#</th>
<th>Databases</th>
</tr>
</thead>
<tbody id="db_grid">
<tr id="db_grid_row1">
<td><input type="checkbox" name="cbox[]" value="1" ></input></td>
<td><input type="text" name="db[]" value="Oracle"></input></td>
<td><input type="hidden" name="modeflag[]" value="S" ></input></td>
</tr>
<tr id="db_grid_row2">
<td><input type="checkbox" name="cbox[]" value="1"></input></td>
<td><input type="text" name="db[]" value="MySQL"></input></td>
<td><input type="hidden" name="modeflag[]" value="S"></input></td>
</tr>
<tr id="db_grid_row3">
<td><input type="checkbox" name="cbox[]" value="1"></td>
<td><input type="text" name="db[]" value="Cassandra"></input></td>
<td><input type="hidden" name="modeflag[]" value="S"></input></td>
</tr>
<tr id="db_grid_row4">
<td><input type="checkbox" name="cbox[]" value="1"></input></td>
<td><input type="text" name="db[]" value="Mongo"> </input></td>
<td><input type="hidden" name="modeflag[]" value="S"></input></td>
</tr>
</tbody>
</table>
</br>
<input type="submit" value="Save"></input></br></br>
</form>
</body>
</html>
函数delrow(){
document.getElementById(“db_grid_row1”).style.display='none';
document.getElementById(“db_grid_row2”).style.display='none';
document.getElementById(“db_grid_row3”).style.display='none';
document.getElementById(“db_grid_row4”).style.display='none';
}
#
数据库
选中复选框并单击“删除”按钮时,我希望
(1) 必须隐藏复选框行。
(2) 更改隐藏行的元素modeflag[]value=“D”
请帮忙。
提前感谢。对于jquery,它是这样的:
$(function() {
$("#del").on('click', delrow);
});
function delrow() {
var checks = $( "input[type=checkbox]:checked" );
checks.parent().parent().hide();
}
注意,我将事件从html元素中删除到javascript中。。
如果您有任何问题,请告诉我您可以使用jquery,还是仅使用纯js?嗨,webkit,它不起作用。我需要包含任何.js文件吗?另外,请您回答我的#2问题:“更改元素modeflag[]value=“D”用于隐藏行”您好,webkit,非常感谢。工作正常,我添加了jquery-1.8.3.min.js文件。请您回答我的#2问题:“为隐藏行@PrakashRaj更改元素modeflag[]value=“D”您还需要关于#2的帮助吗?