如何使用jquery跟踪文本的变化 [英] How to track change in textbox using jquery

查看:147
本文介绍了如何使用jquery跟踪文本的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查,如果用户改变文本框的值。如果用户更改的价值,那么我想显示在不同的文本框中的值更改

I want to check if user changes the value of a textbox. If the user changes the value, then I want to display the changed value in a different textbox.

推荐答案

jQuery有一个这样的事件, .change() ,本次活动将检测内容变化的时候,文本框失去焦点。

jquery has an event for this, .change(), this event will detect content changes when the textbox looses focus.

如果你是想在检测的每个的键preSS,变化 .keyup() .keydown() 可能更适合您的需求。

If you are wanting to detect the change at every keypress, .keyup() and .keydown() might be better suited for your needs.

您的特定用途的例子:

//just change '.change' to '.keyup' or '.keydown' the rest is the same.
$('input').change(function() {
    $('target').val(this.value);
});

这篇关于如何使用jquery跟踪文本的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆