How to remove focus around buttons on click

后端 未结 30 1123
遇见更好的自我
遇见更好的自我 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 04:53

    I just had this same problem on MacOS and Chrome while using a button to trigger a "transition" event. If anyone reading this is already using an event listener, you can solve it by calling .blur() after your actions.

    Example:

     nextQuestionButtonEl.click(function(){
        if (isQuestionAnswered()) {
            currentQuestion++;
            changeQuestion();
        } else {
            toggleNotification("invalidForm");
        }
        this.blur();
    });
    

    Though if you're not using an event listener already, adding one just to solve this might add unnecessary overhead and a styling solution like previous answers provide is better.

提交回复
热议问题