jquery不起作用,点击delete时不弹出提示框,直接跳转到删除页面

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

    <%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

            <script type="text/javascript" src="scripts/jquery-1.9.0.min.js"></script>

            <script type="text/javascript">

            

             $(document).ready(function(){

                    //点击delete时,弹出确定要删除xx的信息

                     $(".delete").click(   function(){

                             var flag =confirm("确定要删除信息 ?");

                             if(flag){

                            

                             }

                             //取消超链接的默认行为

                             return false;

                             });

                     })


            </script>

</head>

<body>

<h4>Employee List Page</h4>

<s:if test="#request.employees ==null //#request.employees.size() == 0">

没有员工信息

</s:if>

<s:else>

<table border="1" cellpadding="10" cellspacing="0">

             <tr>

                     <td>ID</td>

                     <td>LASTNAME</td>

                     <td>EMAIL</td>

                     <td>BIRTH</td>

                     <td>CREATETIME</td>

                     <td>DEPT</td>

                     <td>DELETE</td>

             </tr>

             <s:iterator value="#request.employees">

                     <tr>

                         <td>${id}</td>

                         <td>${lastName}</td>

                         <td>${email}</td>

                         <td>${birth}</td>

                         <td>${createTime}</td>

                         <td>${department.departmentName}</td>

                         <td>

                         <a href="emp-delete?id=${id}" class="delete">Delete</a>

                         <input type="hidden" value="${lastName}">

                         </td>

             </tr>

          </s:iterator>

</table>

</s:else>

</body>

</html>


回到原点co
浏览 1445回答 1
1回答

街角小林

因为点击的是个a标签啊,有默认跳转的事件,你得先禁掉,e.prevetDefault()
打开App,查看更多内容
随时随地看视频慕课网APP