8

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

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

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.

1 Answer 1

11

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.

Update:

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

Sign up to request clarification or add additional context in comments.

4 Comments

Also using the pound selector for IDs '#ADRESTextBox' is a bit more standard.
@Spencer Ruport: If the full ID is ADRESTextBox, then yes of course. But the code uses the ends with selector, so it might be that several input boxes are selected.
A note, the poster may be using the selector syntax [name$=] to select multiple textareas at once, so the changes are made together. So they are not synonymous, although that could be what the poster needs (can't tell without more info).
Oh my mistake! I didn't realize that was an ends-with selector.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.