neilhem neilhem - 2 years ago 109
Javascript Question

Click event not fired on button with svg element in Safari

In Safari click event not fired on button with svg element. When you click on buttons edge click event fires, but if you click on svg element itself does not.

$(document).on('click', 'button', function(e) {

It works if I attach click event like this:

$('button').on('click', function(e) {

Because of buttons added dynamically I can't do like this;

Example in

Answer Source

I don't know is it the best way to solve this problem, but adding pointer-events: none; to svg element solved problem.

svg.icon {
  pointer-events: none;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download