$(document).on("click", "#button1", function (event) {
$("#container").load("page1.php");
}
$(document).on("click", "#button2", function (event) {
$("#container").load("page2.php");
}
大家好!
我的问题是加载多个按钮操作。怎么会这样。
当我点击 button1
时,page1.php
正在加载,没有问题,但当我点击 button2
page2 时,没有刷新页面。 php
加载了两次,当我再次单击时,它加载了 3 次...
我只想加载一次。我从检查元素检查
event.preventDefault();
并不能解决这个问题...
最佳答案
$(document).off('click').on("click", "#button1", function (event) {
$("#container").load("page1.php");
}
$(document).off('click').on("click", "#button2", function (event) {
$("#container").load("page2.php");
}
关于javascript按钮在其他按钮中重复操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33199853/