gpt4 book ai didi

javascript - 禁用 Esc 键以关闭 jQuery Mobile 上的面板

转载 作者:太空宇宙 更新时间:2023-11-03 18:23:51 24 4
gpt4 key购买 nike

根据 jQuery Mobile 的文档:

"Clicking the link that opened the panel, swiping left or right, or tapping the Esc key will close the panel. (...) By default, panels can also be closed by clicking outside the panel onto the page contents."

http://api.jquerymobile.com/panel/

同一文档显示了如何关闭“滑动关闭”和“点击外部关闭”。

但是如何禁用 Esc 键关闭呢?

最佳答案

你可以这样做:

$("body").on("keyup", function(e){
if (e.which === 27){
return false;
}
});

这将在面板打开时禁用转义键关闭面板。这可能会干扰其他功能,您可能可以指定要将事件附加到哪个元素。您可以阅读有关return false here 的更多信息.

我做了一个 very simple and lazy example 它的工作。

关于javascript - 禁用 Esc 键以关闭 jQuery Mobile 上的面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21289290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com