如何使用jQuery将在一个文本框中输入的值反映到另一个文本框中 [英] how to reflect value entered in one text box to another text box using jquery

查看:425
本文介绍了如何使用jQuery将在一个文本框中输入的值反映到另一个文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示在一个文本框中输入的数据,而在另一文本框中显示

i want to display data entered in one text box reflect on another text box

就像我在TextBox1上输入任何东西一样,我应该进入TextBox2(像反射之类的东西)

like if i enter any thing on TextBox1 i should get in TextBox2 (somthing like reflection)

这是我尝试过的..

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(".valueEnter").click(function () {

    $('#message').html($('#textBox').val());

    });
</script>
</head>

<body>

<div>
    TextBox 1 : <input type="textbox" id="textBox" class="valueEnter"></input>

    TextBox 2 : <input type="textbox" id="message"></input>
</div>

</body>
</html>

推荐答案

您可以简单地使用按键功能

you can simple use key up function

http://jsfiddle.net/DfHSS/

$("#textBox").keyup(function(){
   $("#message").val($(this).val());
});

这篇关于如何使用jQuery将在一个文本框中输入的值反映到另一个文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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