+ 1

JavaScript

What is the purpose of inner.HTML? Thank you~

22nd Feb 2020, 4:50 PM
Yan Yan
Yan Yan - avatar
7 Réponses
0
innerHTML = "Some new text" innerText = "Some new text" TextContent = "Some new text" and document.createTextNode("Some new text") All of these add text to an HTML element to better understand look at my code, it's all coded using JS no HTML or CSS https://code.sololearn.com/W5XYF137A18u/?ref=app
22nd Feb 2020, 11:51 PM
JS LOVER
JS LOVER - avatar
+ 9
innerHTML - lets you edit the HTML inside an element on your page.
22nd Feb 2020, 5:27 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 6
It returns everything inside an element. It will return not only the text, but also the tags and attributes
22nd Feb 2020, 5:12 PM
Jax
Jax - avatar
+ 1
If you mean innerHTML ( without point) is how you access the text of the label, span and others ( not input).
22nd Feb 2020, 5:09 PM
Gabriel Ilie
Gabriel Ilie - avatar
+ 1
Yes. Jax is correct. My bad.
22nd Feb 2020, 5:15 PM
Gabriel Ilie
Gabriel Ilie - avatar
+ 1
The property textContent is very practical for text, because in practice, when accessing the text content of an element, one is often not interested in whether and which additional markings were used.
22nd Feb 2020, 5:32 PM
JaScript
JaScript - avatar
+ 1
Thank you guys!
23rd Feb 2020, 3:00 AM
Yan Yan
Yan Yan - avatar