jQuery - link hides div

38 Views Asked by At

I have this simple script

$(".showHide").click(function (e) {
    e.stopPropagation();
    $(".showHide").children('.showHide').toggle();
});

$(".modal-inside").click(function (e) {
    e.stopPropagation();
});

$(document).bind('keydown', function(e) { 
        if (e.which == 27) {
            $(".showHide").children('.showHide').hide();
        }
    });

I cant find out how I can make my link with class close to work. I want it to show .modal div with it.

working script is here https://jsfiddle.net/zkx9gt2u/12/

2

There are 2 best solutions below

0
On

add

$(".close").click(function (e) {
    e.stopPropagation();
    $(".showHide").children('.showHide').toggle();
});

jsfiddle

0
On

Add this:

$(function(){
  $('.close').click(function(){
    $('.showHide').children().toggle();
  });
});

Here's an updated fiddle:

jsfiddle

Press X to close.