我有一个jQuery的对话,其中如下初始化热键:jQuery热键 - 解除绑定?
<script type="text/javascript">
$(document).bind('keydown', '<%=(i+1)%>',function (evt) {
// do stuff
});
</script>
这遍历1-9 ...
问题是,如果你关闭对话框,然后重新打开对话框。它保持重新绑定,所以当你对'1'进行一次按键时,它会运行两次,三次,四次等......它只是在不断增长。
我试着用
$(document).unbind('keydown', '1');
$(document).unbind('keydown', '2');
$(document).unbind('keydown', '3');
$(document).unbind('keydown', '4');
$(document).unbind('keydown', '5');
$(document).unbind('keydown', '6');
$(document).unbind('keydown', '7');
$(document).unbind('keydown', '8');
$(document).unbind('keydown', '9');
杀戮对话框关闭键绑定但是,没有任何效果。有关如何处理这个问题的任何想法?
感谢
你试过`.die()`http://api.jquery.com/die/ – Rafay 2011-02-04 19:18:14