【问题标题】:Why Values in the text field can't be selected by jQuery.select()为什么 jQuery.select() 无法选择文本字段中的值
【发布时间】:2015-10-25 12:13:00
【问题描述】:

我正在尝试使用jQuery.Select 函数在表格中选择文本字段的值。但它不起作用。 这是jsFiddle: - https://jsfiddle.net/zkcxoyzL/3/

jQuery 代码

$(function(){
   $("#acquisition_table").on("focus", "[type='text']", function () {
                $(this).select();
   });
});

看起来,它会在几分之一秒内选择并自动取消选择。

【问题讨论】:

标签: jquery html


【解决方案1】:

$(function() { $("#acquisition_table").on("focus", "[type='text']", function () { var $this = $(this); $this.select(); // Work around Chrome's little problem $this.mouseup(function() { // Prevent further mouseup intervention $this.unbind("mouseup"); return false; }); }); });

取自https://stackoverflow.com/a/5797700/1139130

【讨论】:

  • 谢谢!。所以这是 chrome 的问题。
猜你喜欢
  • 1970-01-01
  • 2012-09-24
  • 1970-01-01
  • 1970-01-01
  • 2011-07-19
  • 2021-07-30
  • 2016-06-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多