使用jQuery填充文本框 [英] Fill a textbox with jQuery

查看:121
本文介绍了使用jQuery填充文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用此代码时,它不想工作。

When I use this code, it doesn't want to work.

$('[id$=ADRESTextBox]').text(data[0]);

您可以看到数据是一个数组。它确实有一个值(因为我提醒它)
如何用jQuery填充某个文本框。

The data is an array as you can see. It really has a value (because I alerted it) How do you fill a certain textbox with jQuery.

推荐答案

使用 val() 设置表单元素的值:

Set values of form elements with val():

$('[id$=ADRESTextBox]').val(data[0]);

如果你在谈论文字 输入元素:他们无论如何都没有内容。它是一个单独的自动关闭标记,因此任何将放入标记内的尝试都将失败。文本字段的值由其属性定义。

If you are talking about text input elements: They don't have "content" anyway. It is a single, self-closing tag, so any attempt to put something inside the tag will fail. A text field's value is defined by its value attribute.

更新:

关于评论:如果 ADRESTextBox 实际上是完整ID,请使用 $(' #ADRESTextBox')选择元素。

With respect to the comment: If ADRESTextBox is actually the full ID, use $('#ADRESTextBox') to select the element.

这篇关于使用jQuery填充文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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