jQuery click events firing multiple times

后端 未结 25 2802
不知归路
不知归路 2020-11-22 11:01

I\'m attempting to write a video poker game in Javascript as a way of getting the basics of it down, and I\'ve run into a problem where the jQuery click event handlers are f

25条回答
  •  猫巷女王i
    2020-11-22 11:27

    Another solution I found was this, if you have multiple classes and are dealing with radio buttons while clicking on the label.

    $('.btn').on('click', function(e) {
        e.preventDefault();
    
        // Hack - Stop Double click on Radio Buttons
        if (e.target.tagName != 'INPUT') {
            // Not a input, check to see if we have a radio
            $(this).find('input').attr('checked', 'checked').change();
        }
    });
    

提交回复
热议问题