How can I trigger a div after e.preventDefault()

时间:2016-07-11 21:19:42

标签: javascript jquery

http://codepen.io/anon/pen/dXkoYp

Hello I am trying to trigger this popup after the line, I need this line to stop the page from anchoring

         e.preventDefault();

I have tried to trigger it using this below but nothing shows up

        $('div#popup1').trigger('click');

The expected result is this http://codepen.io/anon/pen/AXbvXZ

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

Remove onclick event attribute at div#popup1 element, e.preventDefault(), add click event at div#popup, set .overlay .css() opacity to 1 at div#popup1 click event handler. Not certain how to update codepen

$("#stopRed").on("click",function(e){
    $("div#popup1").trigger('click');
});

$("div#popup1").click(function() {
  $(".overlay").css("opacity", 1)
});