Two-way data-binding is sooo 2009.
You're probably wondering what HTML attributes are set when exchanging data with the DOM. You have come to the right place. Here's a brief summary.
input[type=checkbox]
Checkboxes always return boolean true
or false
, regardless of their value
attribute.
input[type=radio]
As you might expect, radio buttons will give you the value
of the selected radio button.
input[type=text, tel, url, ...]
All other input
s use the value
attribute to get and set their value.
select
Select elements work just as expected, using the value
of the selected option
.
In no value
attribute is present on the selected option
, then the text content of the option
is used,
just like a normal form submit.
div
, p
, h1
, span
, ...)The textContent
(or innerText
for IE) attribute is used to get and set values in DOM nodes.