在输入文本框中获取值 [英] Get the value in an input text box

查看:114
本文介绍了在输入文本框中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



以下是一个:

<$>

使用jQuery获取和呈现输入值的方法有哪些? p $ p> < script type =text / javascriptsrc =http://code.jquery.com/jquery-1.4.3.min.js>< / script>
< script type =text / javascript>
$(document).ready(function(){
$(#txt_name)。keyup(function(){
alert($(this).val());
});
})
< / script>

< input type =textid =txt_name/>


解决方案

  //获得
var bla = $('#txt_name')。val();

//设置
$('#txt_name')。val(bla);


What are the ways to get and render an input value using jQuery?

Here is one:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js" ></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#txt_name").keyup(function(){
            alert($(this).val());
        });
    })
</script>

<input type="text" id="txt_name"  />

解决方案

//Get
var bla = $('#txt_name').val();

//Set
$('#txt_name').val(bla);

这篇关于在输入文本框中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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