$("input").click(function(e){
  $(this).select();
});

上述方法在firefox和IE下都正常(注意,不要用focus方法,有时也不正常),唯独在chrome中有时成功有时失败。解决方法如下:

阻止chrome自己的mouseup事件即可。

$("input").mouseup(function(e){
    if(window.navigator.userAgent.indexOf("Chrome")!=-1){
        var event = e||window.event; 
        event.preventDefault(); 
    }
});

 

 

相关文章:

  • 2023-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-12-20
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案