問題がボタン内のテキストを選択しているなら、あなたはボタンにnoselect
クラスを追加することができ、あなたはそのためのJSを使用する必要はありません。しかし、多分私は間違っています。あなたがMacをご述べたコメントで
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
}
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
}
/*maybe give it a static background .. */
button{
background:yellow;
}
button:active{
background:yellow!important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="class1 noselect">Click Me</button>
私はクロームでそれをテストし、私のために、それはあなたが言うことを行いません。それはうまく動作します。 – jakob
あなたのクロムバージョンは何ですか?スクリーンショットを共有してください。作成したコードと見栄えがいい - http://codepen.io/nagasai/pen/VjBYzW –
Chromeバージョン51.0.2704.103(64ビット)私はMacにもいます。 –