将输入更改为大写

编程入门 行业动态 更新时间:2024-10-13 14:28:51
本文介绍了将输入更改为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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。

Why is this still not working?? Just trying to call div ".keywords" from JS.

推荐答案

我认为最优雅的方式是没有任何javascript但是用css 。您可以使用 text-transform:uppercase (这是内联的想法):

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

修改:

因此,在您的情况下,如果您希望关键字为大写更改: 关键字:$(。keywords)。val(), to $(。keywords)。val()。toUpperCase(),

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

更多推荐

将输入更改为大写

本文发布于:2023-10-27 10:38:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为大

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!