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".

推荐答案

I think the most elegant way is without any javascript but with css. You can use text-transform: uppercase (this is inline just for the idea):

<input id="yourid" style="text-transform: uppercase" type="text" />

Edit:

So, in your case, if you want keywords to be uppercase change: keywords: $(".keywords").val(), to $(".keywords").val().toUpperCase(),

Jquery相关问答推荐

Bootstrap 3模态框和video.js视频未正确调整大小

使用 Bootstrap 3 下拉菜单作为上下文菜单

可以推迟 jQuery 的加载吗?

是否可以使用 javascript 打开一个弹出窗口,然后检测用户何时关闭它?

使用 jQuery 和 HTML 导出为 CSV

Jquery .on('scroll')在滚动时不触发事件

如何使用Angular 检测浏览器后退按钮单击事件?

jQuery UI 对话框 - 关闭后不打开

如何重新启用 event.preventDefault?

.apply jQuery 函数是什么?

类方法中的Typescript this

Backbone.js - 事件,知道点击了什么

jQuery:如何找到父母的特定子元素?

如何在纯 JavaScript 中模拟鼠标悬停以激活 CSS:悬停?

如何使用 javascript 展开和折叠

如何在调用 Ajax 等异步调用时让代码等待

自调用函数前的分号?

如何使用 jQuery 或仅使用 Javascript 将按钮重定向到另一个页面

Jquery 日期 Select 器 z-index 问题

如何使用 jQuery 处理复选框的更改?