Joh*_*ohn 3 jquery html5 jquery-selectors
我想在用户点击按钮时选择textarea字段.我的代码:
<textarea readonly="readonly"> </textarea> <input type="button" value="Code"/>
Run Code Online (Sandbox Code Playgroud)
Jquery代码:
$(function() {
$(input:button').click(function(){
('textarea').select();
});
});
Run Code Online (Sandbox Code Playgroud)
它不起作用.
你的意思是:
$("input[type='button']").click(function(){
$('textarea').focus();
$('textarea').select(); //select text inside
});
Run Code Online (Sandbox Code Playgroud)