Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery colorbox fires on clicks even though if statement is false
    primarykey
    data
    text
    <p>I'm using the following jQuery code to shuffle the video links on the left side of <a href="http://www.contagion-game.com/media/" rel="nofollow">this website</a></p> <pre><code> $(document).on("click", ".cboxVideo", function() { var elementURL = $("a", this).attr("href"); $(this).colorbox({iframe: true, href: elementURL, innerWidth: 645, innerHeight: 509}); }); $("#videoFront").addClass("cboxVideo"); $("#videoFront").hover( function() { $(".playVideo", this).fadeTo(300, 1); }, function() { $(".playVideo", this).fadeTo(300, 0.35); }); $("#videoFront").click( function(event) { if($(this).hasClass("cboxVideo")) { event.preventDefault(); } else { event.preventDefault(); // Move behind UP and infront DOWN $(this).animate({top: 155}, 300, function() { $(this).css("z-index", "20"); }); $("#videoBack").animate({top: -95}, 300, function() { $("#videoBack").css("z-index", "10"); }); // Move behind DOWN and infront UP $(this).animate({top: 62}, 300); $("#videoBack").animate({top: -3}, 300); $("#videoBack").removeClass("cboxVideo"); $(this).addClass("cboxVideo"); } }); $("#videoBack").hover( function() { $(".playVideo", this).fadeTo(300, 1); }, function() { $(".playVideo", this).fadeTo(300, 0.35); }); $("#videoBack").click( function(event) { if($(this).hasClass("cboxVideo")) { event.preventDefault(); } else { event.preventDefault(); // Move behind UP and infront DOWN $(this).animate({top: -95}, 300, function() { $(this).css("z-index", "20"); }); $("#videoFront").animate({top: 155}, 300, function() { $("#videoFront").css("z-index", "10"); }); // Move behind DOWN and infront UP $(this).animate({top: -3}, 300); $("#videoFront").animate({top: 62}, 300); $("#videoFront").removeClass("cboxVideo"); $(this).addClass("cboxVideo"); } }); </code></pre> <p>So, if you click on the video that is in the back, it goes to the front. Then if you click the video that is in the front, it opens a popup div containing the video.<br /> I'm using colorbox for the popup and the video is embedded from YouTube.</p> <p>The problem is this.</p> <p>Once I've clicked on the video that is in the front and the colorbox function has fired, it totally neglects my if else statement for future clicks. So if I click the 2nd video (that's currently in the back) so that it goes to the front, and the one I just watched goes to the back, Even though the video is now in the back, when I click it again, the colorbox plugin fires -.-</p> <p>How do I solve that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload