我有我的代码:
+function($) {
'use strict';
var Ripple = function(element) {
var $this = $(this)
$(element).on('mousedown', $this.start)
}
Ripple.prototype.start = function(e) {
var $this = $(this)
var r = $this.find('.ripple-wave')
if(r.length == 0) {
$this.prepend('<div class="ripple-wave"></div>')
r = $this.find('.ripple-wave')
}
if($this.hasClass('btn') || $this.hasClass('single-action')) {
var posX = $(this).offset().left, posY = $(this).offset().top
r.css('left', e.pageX - posX)
r.css('top', e.pageY - posY)
}
r = r.parent()
r.addClass('active')
r.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
r.removeClass('active')
})
}
var old = $.fn.ripple
$.fn.ripple = function() {
return this.each(function() {
new Ripple(this)
})
}
$.fn.ripple.Constructor = Ripple
$.fn.ripple.noConflict = function () {
$.fn.ripple = old
return this
}}(jQuery);
但是如果我在 Mozilla Firefox 上测试,我必须双击该元素才能执行其功能。
我使用以下方法将其初始化为我的页面加载:
$('.ripple').ripple()
PS:我还有来自其他 JS 文件的每个元素的点击事件。
在 chrome 中,只需单击一下即可正常工作。
最佳答案
$( "p" ).dblclick(function() { alert( "Hello World!" ); });
<p ondblclick="myFunction()">Double-click me</p>
关于javascript - 需要双击 Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33362495/