I am using the following code for closing the popup using ESC Key. But after ESC button is pressed the link used to create pop up becomes disabled.
$(document).keydown(function(e) {
if (e.keyCode == 27) {
$(".overlay").hide();
}
});
This is the HTML code
<a href="#popup1
<li>bla bla</li>
</a>
<div id="popup1" class="overlay">
<div class="popup">
<a class="close" href="#">×</a>
<div class="content">
<p>Hello</p>
</div>
</div>
</div>
答案 0 :(得分:1)
希望这会对你有所帮助。
$(document).keydown(function(e) {
if (e.keyCode == 27) {
$(".overlay").hide();
}
});
$("your-a-tag-id-or-class").click(function(e) {
e.preventDefault();
$(".overlay").show();
});