Getting and Setting Text Input Values

var inText = $("#inBox").val(); if (inText != "default"){   $("#outBox").val(inText); }

The most common type of form elements are textual inputs. These elements include the <textarea> element as well as <input> elements with the following type attribute values: color, date, datetime, datetime-local, email, month, number, password, range, search, tel, text, time, url, and week.

Although the browser uses these values a bit differently, all are rendered in the same basic text box and are accessed in the same basic way. Each of them has a value attribute that is displayed in the text box as the image is rendered.

In jQuery, you can access the value text inputs using the .val() ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.