0

there is a link on my website. When I click on it a colorbox opens with some content.

There is a link in the colorbox's content and I want to add a click event on that link but its not working.

$('.link').on('click', function() {
alert('a');
});
Ahmad
  • 2,099
  • 10
  • 42
  • 79

1 Answers1

1

Jquery only works with elements that are loaded. make sure that you are setting up this code after the colorbox is loaded. you can do that by wrapping it in a $(doument).ready(function(){}); on the colorbox html page

$(doument).ready(function(){
    $('.link').on('click', function() {
           alert('a');
     });
});
M B
  • 2,326
  • 24
  • 33