如何通过javascript使元素鼠标不可点击但可点击?

如何通过javascript使元素鼠标不可点击但可点击?,javascript,javascript-events,jquery,Javascript,Javascript Events,Jquery,我在jQuery中使用翻转插件,它翻转给定的div 代码(重用某人的代码)在您单击某个元素后将其翻转 我有几个图像,通过使用此功能,我试图创建一个动画。我正在使用jQuery单击这些图像。然而,问题是,即使用户可以单击图像,然后再次翻转我不想要的图像 我尝试使用CSS属性: body{pointer-events:none;} 这是可行的,但在完成动画后,我无法使用jQuery禁用此功能。我试过: $('body').css('pointer-events','normal')

我在jQuery中使用翻转插件,它翻转给定的div

代码(重用某人的代码)在您单击某个元素后将其翻转

我有几个图像,通过使用此功能,我试图创建一个动画。我正在使用jQuery单击这些图像。然而,问题是,即使用户可以单击图像,然后再次翻转我不想要的图像

我尝试使用CSS属性:

    body{pointer-events:none;}
这是可行的,但在完成动画后,我无法使用jQuery禁用此功能。我试过:

    $('body').css('pointer-events','normal');
我正在重用的代码是:

$(document).ready(function() { /* The following code is executed once the DOM is loaded */


    $('.sponsorFlip').bind("click", function() {

        // $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):
        var elem = $(this);

        // data('flipped') is a flag we set when we flip the element:
        if (elem.data('flipped')) {
            // If the element has already been flipped, use the revertFlip method
            // defined by the plug-in to revert to the default state automatically:
            elem.revertFlip();

            // Unsetting the flag:
            elem.data('flipped', false)
        }
        else {
            // Using the flip method defined by the plugin:
            $(this).unbind("click");
            $(this).unbind("click");
            $(this).unbind("click");
            elem.flip({
                direction: 'lr',
                speed: 350,
                onBefore: function() {
                    // Insert the contents of the .sponsorData div (hidden from view with display:none)
                    // into the clicked .sponsorFlip div before the flipping animation starts:

                    elem.html(elem.siblings('.sponsorData').html());
                }
            });

            // Setting the flag:
            elem.data('flipped', true);


        }
    });

});
我试图添加

    $('.sponsorFlip').unbind("click");
它也不起作用

$('.sponsorFlip').on('click', function(e) {
   // for a click event by mouse has e.clienX/e.clientY 
   if(e.clientX){
      // then click by mouse
   } else {
      // triggered 
   }
});

为您的代码

$('.sponsorFlip').bind('click', function(e) {
   // for a click event by mouse has e.clienX/e.clientY 
   if(e.clientX){
      // then click by mouse
   } else {
      // triggered 
   }
});

将其分配给单击事件,然后模拟单击,然后取消分配单击事件,这似乎有点像黑客。为什么不创建一个直接翻转元素的函数呢

var options = {...};
$(element).flip(options);

要快速解决问题,请尝试删除以下行:

 // If the element has already been flipped, use the revertFlip method
        // defined by the plug-in to revert to the default state automatically:
        elem.revertFlip();

        // Unsetting the flag:
        elem.data('flipped', false)