DevKev
DevKev

Reputation: 6304

Why won't my popups close?

Site: http://bit.ly/1dPAXsS

I can't figure out why my popups won't close. Have been debugging for too long 0_o Click "Credit Card Inform Me When Available" to open popup

I have the following js:

// Popup
jQuery(".showpop").click(function () {

    var NewHeight = $(this).offset().top + $(this).height();
    jQuery("#light").css({
        'top': NewHeight + 'px'
    });
    jQuery("#light").show();
    jQuery("#fade").show();
});
jQuery(".hidepop").click(function () {
    jQuery("#light").hide();
    jQuery("#fade").hide();
    return false;
});

I have tried using $ instead of jQuery, changed the target ids/classes and it still won't close.

This is similar to http://jsfiddle.net/techrevolt/K2TBa/

Upvotes: 0

Views: 161

Answers (1)

kenttam
kenttam

Reputation: 740

The element was not loaded on the page when you made the call. What you want to do is wrap in a jquery document ready call like so:

$(document).ready(function(){
    $(".hidepop").click(function(){
        $("#light").hide();
        $("#fade").hide();
    });
});

http://api.jquery.com/ready/

Upvotes: 1

Related Questions