[英]Why does the code in my onclick event after a confirm not run?
考虑以下代码:
<a href="#" onclick="return confirm("sure to remove?");;
new Ajax.Updater('12', '/admin/files/remove/id/12', {asynchronous:true, evalScripts:false});;
return false;">Remove
</a>
它不起作用,我不知道为什么。
我该如何解决这个问题?
在return
语句之后没有执行任何操作。 当你回来时,你回来了。 这就是return
所在。 因此没有代码后return confirm("sure to remove?");
将永远运行。
你可能想要这样的东西:
<a href="#" onclick="
if (confirm("sure to remove?")) {
new Ajax.Updater('12', '/admin/files/remove/id/12', {asynchronous:true, evalScripts:false});
}
return false;">Remove</a>
尽管创建一个适当的函数并调用它会好得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.