开发者

highlighting disabled in browser

I have a simple pagination script. When you click the "next" button multiple times in a short period of time, the browser highlights the clickable area. All browsers do this to an element that you click repeatedly.

Is there a way to disable the开发者_运维技巧 highlighting of that element?

I feel like I've looked everwhere and cannot find an answer.

Thank You!


Very difficult to do this cross-browser. I usually just assume that IE users are used to stuff looking a little off/wont notice the highlight/etc. I use this snippet which uses jQuery but should be adaptable to pretty much any library:

$.fn.disableSelection = function() {
  return $(this).each( function( index, el ) {
    if( typeof el.style.MozUserSelect != 'undefined' ) {
      el.style.MozUserSelect = 'none';
    }
    else {
      el.onmousedown = function() { return false; }
    }
    el.style.cursor = 'pointer';
  } );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜