0

I'm using jQuery to make somethings after a click on some elements of my page :

$('.news-comment-tablink, #news-comment-count, #fast-travel-sparking').click(function(){
    console.log('test');
});

All the three elements are on my page, I see them when analysing my code.

But if I have the 'test' in my console on Firefox on each elements, in Chrome, the 'test' appear only on one of them !

I'm not bad in jQuery, but this time I really don't know what to do...

Can you help ?

DarkCid
  • 227
  • 1
  • 3
  • 18
  • I believe you are using a depreciated functionality. Try this instead: `$(document).on('click','.news-comment-tablink, #news-comment-count, #fast-travel-sparking', function(){`. If it works, I'll add it as an answer. – Mech Jul 15 '20 at 20:23
  • @Mech if was was deprecated, then it would not be not obsolete nor removed, but it's not anyway because they decided it would break too much existing code. `$().click(function` is fine. – freedomn-m Jul 15 '20 at 20:25
  • Can you include a [mcve] in a snippet here that demonstrates the issue? – freedomn-m Jul 15 '20 at 20:26

1 Answers1

0

I tried your code and the code works correctly on Chrome. However on chrome, you will see "Test" only appears once as Chrome's Console groups similar logs.

I assume that would be your issue, you'll see the first call being listed in the console, the second and third would just be grouped in the first log.

Uzair Hayat
  • 518
  • 1
  • 8
  • 21