JS Fiddle Example
我使用导航栏中的“ FOO”,“ BOO”项来操作下拉框,并在外部发生点击事件时使用以下代码关闭了它们,这些代码工作正常。
$(document).on('click', '.dd-box', function() {
// Comment out the return statement below and the links will start working.
return false
});
我遇到的问题是,这也阻止了下拉框中的链接被访问。
我需要此代码的原因是,当其中发生单击事件时,我不希望下拉框关闭。
我试图避免使用诸如window.open之类的hack强制访问该链接,有什么想法吗?
最佳答案
你应该把stopPropagation
$(document).ready(function() {
$("a").click(function(e) {
e.stopPropagation();
});
...
see JSFiddle
关于javascript - 由于JS而无法点击的链接返回false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44212614/