2015-08-03 68 views
1

我試圖使用jQuery.Select函數來選擇表中文本字段的值。但它不起作用。 這裏是它的jsFiddle: - https://jsfiddle.net/zkcxoyzL/3/爲什麼jQuery.select()不能選擇文本字段中的值

jQuery代碼

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

看來,它選擇和自動幾分之一秒內將取消。

+0

採取下面是解http://stackoverflow.com/questions/5797539/jquery-select-all-text-from-a-textarea – Kerem

回答

2

$(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

+0

謝謝!所以這是鉻的問題。 – trex

相關問題