Javascript/Jquery-重置选项卡后的文本框视图区域
我不知道这叫什么,所以很难用谷歌搜索 如果您有一个纯html输入类型=文本,宽度很小,例如20,然后键入的字符超过了可以显示的字符数,那么它将显示您键入的最后一个字符。第一个将从视图中滚出:Javascript/Jquery-重置选项卡后的文本框视图区域,javascript,jquery,textbox,input,Javascript,Jquery,Textbox,Input,我不知道这叫什么,所以很难用谷歌搜索 如果您有一个纯html输入类型=文本,宽度很小,例如20,然后键入的字符超过了可以显示的字符数,那么它将显示您键入的最后一个字符。第一个将从视图中滚出: This is my long text // this is the whole string my long string // this is what is actually visible in the input box 如何使其在点击tab键时,视图区域重置,以便字符串的开头可见,结尾隐藏
This is my long text // this is the whole string
my long string // this is what is actually visible in the input box
如何使其在点击tab键时,视图区域重置,以便字符串的开头可见,结尾隐藏
my long string // this is what is visible in the input box when typing
This is my // this is what is I want to be visible in the input box after you hit tab
这叫什么?你是怎么做的?我不知道你的问题是否得到了回答,但我只是想回答我自己。您可以通过使用范围和窗口选择来实现这一点
对不起@JK,我让你失望了。我已经删除了我的答案。即使如此,你可能还是想重新提问,因为这个问题现在可能有点过时了。
$(document).ready(function(){
$("input").bind("keyup",function(e){
if(e.keyCode==9){
var r=document.createRange(),
gs=getSelection();
r.setStart(this,0);r.setEnd(this,0);
gs.removeAllRanges();gs.addRange(r);
}
});
$("input").bind("blur"),function(){
$(this).focus();
});
});