该脚本为每一行创建一个按钮。但是这些按钮“ onclick”似乎都不起作用。我从其他帖子中尝试了多种方法和解决方案,似乎没有什么不同。
<div class="table-wrapper">
<head><script>
function decrypt(text){
alert("Test");
//type="text\javascript" src="../routes/crypt.js"><
}
</script></head>
<title><%= title %></title>
<link rel="stylesheet" type="text/css" href="/stylesheets/passlist.css"/>
<% if (pass.length > 0) {%>
<table class="PasswordMesh">
<thead class="thead-dark">
<tr>
<th scope="col">Password Name</th>
<th scope="col">Password</th>
</tr>
</thead>
<tbody>
<% pass.forEach((pass, index) => { %>
<tr id = "INFO">
<td><%= pass.passName %></td>
<td><%= pass.passV.substring(0,24) + "..."; %></td>
<td><button type = "button" onclick = "decrypt(pass.passV); return false;" id = "DecryptButton"> Decrypt </button></td>
</tr>
<% }) %>
<tr id = "Add Password">
<td></td>
<td><button class = "AddPassButton" onclick = "location.href = '/addpass';"> Add Password </button></td>
</tr>
</tbody>
</table>
<% } else { %>
<p class="text-center">No passwords found. Go <a href="/addpass" >here</a> to store some.</p>
<% } %>
</div>
</div>
</body>
</html
>