80 javascript jquery
我想使用JavaScript强制文本框的值为小写.我已经尝试了下面的代码,但每次按一下键时光标都会跳到输入的末尾.我怎么能避免这个?
$("#beLowerCase").keyup(function(){
$(this).val( $(this).val().toLowerCase() );
});
Run Code Online (Sandbox Code Playgroud)
nic*_*ass 124
$("#beLowerCase").on('input', function(){
// store current positions in variables
var start = this.selectionStart,
end = this.selectionEnd;
this.value = this.value.toLowerCase();
// restore from variables...
this.setSelectionRange(start, end);
});
Run Code Online (Sandbox Code Playgroud)
(小提琴)
这实际上也适用于CSS:
#beLowerCase{
text-transform:lowercase;
}
Run Code Online (Sandbox Code Playgroud)
服务器可以照顾实际的下壳...
| 归档时间: |
|
| 查看次数: |
43630 次 |
| 最近记录: |