单击文本框可选择所有数据。我现在的代码在所有文本框中选择。但我想在特定的盒子中应用它。 现在的代码:
$(document).ready(function() {
$("input:text").focus(function() {
$(this).select();
});
});
我想仅在搜索框中应用它。 搜索框的代码如下:
<input name="q" id="searchBox" type="text" size="40" placeholder="Search..."/>
答案 0 :(得分:1)
使用#id选择器。就像这个......
$("#searchBox").focus(function () {
$(this).select();
});
答案 1 :(得分:1)
试试这个
$(document).ready(function () {
$("#searchBox").focus(function () {
$(this).select();
});
});