js change element text

 

 

 

 

javascript - JS Change text onClick then change back onClick IfelseAlso, a list of errors in the code you copied, so you can avoid these problems again: The first line of script gets an element with ID change. The JS codeI just want to change the text of an already existing div Alosyius Mar 8 13 at 14:49. Alosyius Give it an id, look for it and use innerHTML to change it. How do I change element content using JavaScript?Update: Using this script, when I click the submit button the text in the paragraph changes to "NEW TEXT" but then immediately changes back to "PARAGRAPH". HEAD>