如何使用'keyup'事件将小写字符更改为大写? [英] How to change lowercase chars to uppercase using the 'keyup' event?
本文介绍了如何使用'keyup'事件将小写字符更改为大写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目标是使用jQuery事件 .keyup()将输入的小写字符转换为大写.
My goal is to use the jQuery event .keyup() to convert inputted lowercase chars to uppercase.
我该如何实现?
推荐答案
普通的javascript:
Plain ol' javascript:
var input = document.getElementById('inputID');
input.onkeyup = function(){
this.value = this.value.toUpperCase();
}
带有jQuery的Javascript:
Javascript with jQuery:
$('#inputID').keyup(function(){
this.value = this.value.toUpperCase();
});
这篇关于如何使用'keyup'事件将小写字符更改为大写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文