我用了this answer禁用 arrow
和 pgdown
和 pgup
键操作(滚动)。但是我需要在我的 jquery
代码中调用 event.preventDefault()
之后将此键的操作设置为默认(滚动)。
我该怎么做。
最佳答案
如果没有更好的细节就很难回答,但是如果我正确地理解了你所拥有的东西,如果你有可以跟踪状态的东西,那么当你希望阻止这种行为并让它失败时,你可以使用 preventDefault:
伪代码:
var state = {
blockArrows: true;
}
$('#my_widget').keydown(function(e) {
if(state.blockArrows) {
e.preventDefault();
}
// ...else allow the event to do its normal thing....///
});
关于javascript - 在 event.preventdefault 之后将事件恢复为 jquery 中的默认操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42498548/