I have a dropdown list which is populated by Javascript.
Whilst deciding what should be the default value to show on load, I realised that the following properties showed exactly the same values:
innerText
innerHTML
label
text
textContent
outerText
My own research shows bench marking tests or comparisons between a few of them, but not all.
I can use my own common sense and choose 1 or the other as they provide the same result, but, I'm concerned this is not going to be a good idea if the data were to change.
My findings are:
innerText
will show the value as is and ignores any HTML formatting which may be includedinnerHTML
will show the value and apply any HTML formattinglabel
appears to be the same asinnerText
, so I can't see the differencetext
appears to be the same asinnerText
but the jQuery shorthand versiontextContent
appears to the same asinnerText
but keeps formatting (such as\n
)outerText
appears to be the same asinnerText
My research can only take me so far as I can only test what I can think of or read what is published, can any one confirm though if my research is correct and if there is anything special about label
and outerText
?