How can I link 2 events in jquery? Can't make them both work

46 Views Asked by At

I would like asking you for some more help about this jquery code, the first part of the code is working perfectly, I wanted an entire <div> to take the link inside the text, so that I could click in the whole box as a button, that's working. What I would like to do now is that whenever someone press that div (.o-neuron-hover) the event of featherlight('iframe', {}) is going to happen, it's a lightbox, not a simple link, the code like this it's not doing anything, the problem is that I don't know where to place the part related to the featherlight, if it should be inside or connected somehow, do you have any idea?

$('.o-neuron-hover').click(function() {
  window.location = $(this).find("a:first").attr("href");

  return false;
});


$('.o-neuron-hover a:first').featherlight('iframe', {});
1

There are 1 best solutions below

0
mplungjan On

NO code after your location change can be expected to run since the browser offloads the page

Perhaps you mean

$('.o-neuron-hover a').on('click', function(e) {
  e.preventDefault(); // stop  link
  $("#myDiv").load(this.href, function() { $.featherLight("#myDiv") });
})

which will load the page the link points at into the div which will be shown in the lightbox

myDiv is ANOTHER div on the page, not the one with the links inside