在jsp中应用引导切换(折叠)

vi4fp9gy  于 2021-07-16  发布在  Java
关注(0)|答案(0)|浏览(231)

我目前正在尝试用toggle制作表。
下面是我现在考虑的逻辑。
用户在看到jsp页面时可以看到原始的表内容
单击每一行时,它会在下面显示另一行,其中包含额外的信息
当用户在第2步中单击的行时,包含额外信息的行将被隐藏。(切换)
问题是,额外的信息显示后,我点击行,但不能使它隐藏与另一次点击。
我只是看到了bootstrap的文档,并使用了相同的代码(只是更改了某个标记的id),但无法找出问题的根源。
有人能看到我的jsp页面代码并帮助我吗?
下面是我刚才看到的引导文档。
https://getbootstrap.com/docs/4.3/components/collapse/

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title>구매내역 조회</title>
  9. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
  10. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  11. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  12. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  13. </head>
  14. <body>
  15. <jsp:include page="../common/header.jsp"/>
  16. <script>
  17. $(function(){
  18. if(${not empty message}){
  19. alert("${message}");
  20. }
  21. })
  22. </script>
  23. <br><br>
  24. <div class="container">
  25. <h2>구매내역 조회</h2>
  26. <br>
  27. &nbsp 구매자 아이디 : ${loginUser.userId}
  28. <table class="table">
  29. <thead>
  30. <tr>
  31. <th>거래번호</th>
  32. <th>구매자명</th>
  33. <th>구매물품</th>
  34. <th>구매수량</th>
  35. <th>등록날짜</th>
  36. <th>수정날짜</th>
  37. <th>구매상태</th>
  38. <th>상태수정</th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. <c:forEach items="${purchaseHistories}" var="purchaseHistory">
  43. <tr>
  44. <td>${purchaseHistory.phNo}</td>
  45. <c:set var="sharp" value="<%='#'%>"/>
  46. <td><a data-toggle="collapse" href="${sharp}detail_${purchaseHistory.phNo}" aria-expanded="false" aria-controls="detail_${purchaseHistory.phNo}">${purchaseHistory.phBuyerName}</a></td>
  47. <td><a href="detail.gb?pNo=${purchaseHistory.phProduct}">${purchaseHistory.phProductName}</a></td>
  48. <td>${purchaseHistory.phQuantity}</td>
  49. <td>${purchaseHistory.phRecordDate}</td>
  50. <td>${purchaseHistory.phChangeDate}</td>
  51. <c:if test="${purchaseHistory.phStatus eq 'N'}">
  52. <td>거래 취소</td>
  53. <td> </td>
  54. </c:if>
  55. <c:if test="${purchaseHistory.phStatus eq 'Y'}">
  56. <c:if test="${purchaseHistory.phSalesStatus eq 'W'}">
  57. <td>거래 대기</td>
  58. <td>
  59. <a class="btn btn-danger btn-sm" href="cancelDeal.gb?phNo=${purchaseHistory.phNo}&phProduct=${purchaseHistory.phProduct}&phBuyer=${purchaseHistory.phBuyer}" onclick=" return cancelDeal();">취소하기</a>
  60. </td>
  61. </c:if>
  62. <c:if test="${purchaseHistory.phSalesStatus eq 'R'}">
  63. <td>발송 준비</td>
  64. <td> </td>
  65. </c:if>
  66. <c:if test="${purchaseHistory.phSalesStatus eq 'C'}">
  67. <td>발송 완료</td>
  68. <td></td>
  69. </c:if>
  70. </c:if>
  71. </tr>
  72. <tr>
  73. <td colspan="8">
  74. <div id="detail_${purchaseHistory.phNo}" class="collapse">
  75. <b>세부정보 조회</b>
  76. <br><br>
  77. <ul>
  78. <li>제품명 : ${purchaseHistory.phProduct}</li>
  79. <li>판매자ID : ${purchaseHistory.phSeller}</li>
  80. <li>받는주소 : ${purchaseHistory.phAddress}</li>
  81. <li>배송정보 : ${purchaseHistory.phInvoice}</li>
  82. </ul>
  83. </div>
  84. </td>
  85. </tr>
  86. </c:forEach>
  87. </tbody>
  88. </table>
  89. </div>
  90. <script>
  91. function cancelDeal(){
  92. return confirm("정말 취소하시겠습니까?");
  93. }
  94. </script>
  95. </body>
  96. </html>

行用户必须单击才能看到隐藏行是具有数据切换属性的标记。隐藏的行是名为“collapse”的类的标记。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题