Close a customized box at ESC keypress with JQuery

I have the following HTML code for dialog box: The javascript : $("#clickfeed").live("click", function() { $("#modal-dialog").removeClass("no-display"); }); I wrote: $("#modal-dialog").live("keyup", function(e) { if(e.keyCode === 27 && !($(this).hasClass("no-display"))) { $("#feedback-modal-dialog input").each(function() { $(this).attr("value",""); }); $("#feedback-modal-dialog textarea").each(function() { $(this).val(""); }); $("#modal-dialog").addClass("no-display"); //or .hide() } }); The `ESC` key works only if an input is focused otherwise not. I want to close `modal-dialog` box when pressed `ESC`. Is a mistake in my JS code ? Thank you
Which version of jQuery are you using?

以上就是Close a customized box at ESC keypress with JQuery的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准