点击后没反应<div style="display:flex; justify-content:center;"> <a ><button id="adds" type="button">增加</button></a> <a ><button id="update" type="button">修改</button></a> <a ><button id="delete" type="button">删除</button></a> <a ><button id="query" type="button">查询</button></a> </div> <script> $(function() { $("#adds").on('click', function() { window.location.href = "add"; }); $("#update").on('click', function() { window.location.href = "update"; }); $("#delete").on('click', function() { window.location.href = "delete"; }); $("#query").on('click', function() { window.location.href = "query"; }); }); </script>
时间: 2023-10-05 11:11:25 浏览: 54
你需要在`window.location.href`后面加上`.html`才能跳转到对应的页面。修改后的代码如下:
```
<div style="display:flex; justify-content:center;">
<a><button id="adds" type="button">增加</button></a>
<a><button id="update" type="button">修改</button></a>
<a><button id="delete" type="button">删除</button></a>
<a><button id="query" type="button">查询</button></a>
</div>
<script>
$(function() {
$("#adds").on('click', function() {
window.location.href = "add.html";
});
$("#update").on('click', function() {
window.location.href = "update.html";
});
$("#delete").on('click', function() {
window.location.href = "delete.html";
});
$("#query").on('click', function() {
window.location.href = "query.html";
});
});
</script>
```
这样就可以正常跳转到对应的页面了。
阅读全文