javascript:void(0)的用途
点击一个链接点击后,页面上不做任何事情,多用于绑定响应事件 如:通过js代码,为其绑定’submit(提交表单事件)’
而且,往往不定义该代码,还可能完成不了所绑定的’submit’事件.
参考:https://zhidao.baidu.com/question/2202019854738731028.html
示例代码:
<script>
window.onload=function (ev) {
function sub(){
alert("表单被提交了");
var formObj = document.getElementById("form").submit;
}
document.getElementById("delselect").onclick=function (ev1) {
var checkedNum = document.getElementsByName("userid");
var checkedBoolean = false;
for (var i = 0;i<checkedNum.length;i++){
if (checkedNum[i].checked) {//判断多选框是否被选中
sub();
break;
}
}
}
}
</script>
<form id="form" action="${pageContext.request.contextPath}/DeleteUserServlet" method="post">
${pageContext.request.contextPath}
<table border="1" class="table table-bordered table-hover">
<tr class="success">
<th><input type="checkbox"></th>
<th>编号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>籍贯</th>
<th>QQ</th>
<th>邮箱</th>
<th>操作</th>
</tr>
<c:forEach items="${list}" var="paraminfo" varStatus="num" >
<tr>
<th><input type="checkbox" name="userid" value="${paraminfo.id}"></th>
<td>${num.count}</td><!-- 编号 根据num数值获取 -->
<td>${paraminfo.name}</td>
<td>${paraminfo.gender}</td>
<td>${paraminfo.age}</td>
<td>${paraminfo.address}</td>
<td>${paraminfo.qq}</td>
<td>${paraminfo.email}</td>
<td><a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/findUserServlet?userid=${num.count}">修改</a> <a class="btn btn-default btn-sm" href="">删除</a></td>
</tr>
</c:forEach>
</table>
</form>