In JQuery when trying to access elements, I see that if I have a form (lets say a textarea
), and I want to get the text
inside of it, I must use
you could use h1.text()
or h1.html()
which map to innerText
and innerHTML
respectively.
As for val()
that maps to input.value
.
Using the jquery equivalents gives you cross-browser compatibility, although that's probably more of a historic relic. New browsers probably implement these features the same way.
As a general rule: value
is used on input elements, innerHTML
on non-input fields.