How to remove focus around buttons on click

后端 未结 30 1117
遇见更好的自我
遇见更好的自我 2020-12-02 04:24

My buttons all have a highlight around them after I click them. This is in Chrome.

\"Unselected\"

30条回答
  •  猫巷女王i
    2020-12-02 05:01

    I mentioned this in a comment above, but it's worth listing as a separate answer for clarity. As long as you don't need to ever actually have focus on the button, you can use the focus event to remove it before it can apply any CSS effects:

    $('buttonSelector').focus(function(event) {
        event.target.blur();
    });
    

    This avoids the flicker that can be seen when using the click event. This does restrict the interface, and you won't be able to tab to the button, but that isn't a problem in all applications.

提交回复
热议问题