jquery keyup 事件取决于 id 参数

标签 jquery

我正在使用 jquery keyup 方法将字母转换为大写,现在可以使用。但是我如何添加异常,以便我的 txtEmail id 不会转换为大写

<input runat="server" clientidmode="static" type="text" id="txtEmail" value="" />
 //Only this emaild should not get change to uppercase 

<input runat="server" clientidmode="static" type="text" id="txtAdd1" value="" />

jQuery:

$("input[type=text]").keyup(function () {
        $(this).val($(this).val().toUpperCase());
    });

我无法更改 HTML 标记。我想在 jquery 本身中完成它。

最佳答案

尝试.not()

$("input[type=text]").not('#txtEmail').keyup(function () {

<小时/> 还可以使用 this.value 而不是 $(this).val() 更快。 <小时/> fiddle 作者:jagruti

关于jquery keyup 事件取决于 id 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20072366/

相关文章:

javascript - 为什么 jQuery 中的 $(this) 不起作用?

javascript - 如何在 Ajax Success 上隐藏多个 div

javascript - 选择除一个以外的所有 div

javascript - 如何在 jQuery 中传递事件和 $ 作为参数(在 wordpress 中启用无冲突模式)

javascript - 如何使用 JQuery 检索单击对象内具有特定类的 span 元素内的文本?

javascript - DataTables.js 对包含带有整数文本的 HTML 链接的列进行排序

执行日期操作的 jQuery 插件

javascript - 想要在一行 jquery 代码中更改 css 的 2 个或多个属性,我该怎么做?

javascript - 如何从html页面调用python命令?

jquery - 即使 jQuery 模板尚未正式发布,我是否应该使用它们?