Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户通过jquery打开它时,如何选择textarea中的所有文本?
$('textarea').on('mouseup', function() { $(this)[0].select(); });
http://jsfiddle.net/Tu9N7/
输入.选择
var eraInput = document.getElementById('era'); eraInput.select();
$('textarea').focus(function() { this.select(); })
演示
$('textarea').slideDown(function() { $(this).focus(); }).focus(function() { this.select(); });
在这里,我假设您textarea是隐藏的,并且您使用 jQuery 事件打开它,打开后默认选择文本。
textarea