Help with InnerHTML | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
29th Aug 2018, 8:35 AM
THATguy18
THATguy18 - avatar
2 Answers
+ 3
document.getElementsByTagName('p')[0].innerHTML
29th Aug 2018, 8:54 AM
Calviղ
Calviղ - avatar
0
<!DOCTYPE html> <html> <head> <title>Page Title</title> <script> function change(){ document.getElementsByTagName("p")[0].innerHTML = 'yay! you did it!'; } </script> </head> <body> <p>cookie monster eats cookies.</p> <button onclick='change()'>change the sentence above</button> </body> </html>
29th Aug 2018, 9:04 AM
Prateek
Prateek  - avatar