jquery – 在Safari中使用svg元素的按钮上未触发的Click事件

栏目: jQuery · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/29814709/click-event-not-fired-on-button-with-svg-element-in-safari

在Safari中,单击事件未在带有svg元素的按钮上触发.当你单击按钮边缘时单击事件会触发,但如果单击svg元素本身则不会.

$(document).on('click', 'button', function(e) {
    console.log(e);
});

如果我附加这样的点击事件,它可以工作:

$('button').on('click', function(e) {
    console.log(e);
});

由于动态添加按钮,我不能这样做;

codepen.io http://codepen.io/neilhem/pen/bdGYPq 中的示例

jQuery版本2.1.3

我不知道这是解决这个问题的最佳方法,但是添加了指针事件:无; svg元素解决了问题.
svg.icon {
  pointer-events: none;
}

翻译自:https://stackoverflow.com/questions/29814709/click-event-not-fired-on-button-with-svg-element-in-safari


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Is Parallel Programming Hard, And, If So, What Can You Do About

Is Parallel Programming Hard, And, If So, What Can You Do About

Paul E. McKenney

The purpose of this book is to help you understand how to program shared-memory parallel machines without risking your sanity.1 By describing the algorithms and designs that have worked well in the pa......一起来看看 《Is Parallel Programming Hard, And, If So, What Can You Do About 》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

html转js在线工具
html转js在线工具

html转js在线工具