Search code examples
phpjqueryfunctionfadeinfadeout

jquery click function not working for me


The source code of my webpage

My code

I want to be able to click on a thumbnail and the get a modal screen with the image. i used php to set the id and class names but it stil isnt working. i looked everywhere to find a solution but cant find any i have tryed this: Why is this jQuery click function not working?. but also this doesnt work the problem isnt with javascript ready function.

$(document).ready(function() {

});

the first 2 querys work when i want to fadeIn the image and the fadeOut when pressed ESC but the last one when i click on my overlay it isnt working please help me.

The one with the red circle isnt working.


Solution

  • there is an error in the code:

    $('#63848').on('click', '#63848', function() { 
    

    this syntax means you are looking fon an element (second selector) inside a parent container (the first one selector). So you can change the parent container to 'body' or what else you want, like this:

    $('body').on('click', '#63848', function(event) { 
    

    or just remove the container

    $('#63848').on('click', function(event) { 
    

    see a working example here of your scenario: FIDDLE