【发布时间】:2011-08-11 01:20:23
【问题描述】:
JS:
<script type="text/css">
$(function() {
$('#upper').keyup(function() {
this.value = this.value.toUpperCase();
});
});
</script>
HTML
<div id="search">
<input type="radio" name="table" class="table" value="professor" tabindex="1" /> Professor
<input type="radio" name="table" class="table" value="department" tabindex="2" /> Department
<input type="radio" name="table" id="upper" class="table" value="course" tabindex="3" /> Course
<input type="text" name="search" class="keywords" value="Select an option..." onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?':this.value;" tabindex="4" />
<div id="content"> </div>
</div>
为什么这仍然不起作用?只是想从 JS 中调用 div ".keywords"。
【问题讨论】:
-
我希望我有时间把我认为最好的答案放在这里。它是处理按键事件并将键码更改为大写(如果适用),使跨浏览器兼容比听起来容易,但我认为这是最好的解决方案。
-
实际上我想的解决方案只适用于 IE...e.which 在 FF 和 WebKit 中是只读的,但 IE 允许您更改 e.keyCode。在 IE 中试试这个 jsfiddle.net/48fSq/1
标签: javascript jquery