0

Is there any way to add some code inside another html file with javascript like

document.getElementById("demo").innerHTML
4
  • Let's suppose you have two html files: a.html and b.html. Inside a.html do you want to write some JavaScript code that modify the html in b.html? Is this your question? Commented Aug 15, 2015 at 8:49
  • There is a huge difference bettween editing a html file, and adding content inside it inside the page itself. What do you want? If you want to add more elements, texts to your page, see biancamihai's answer, if you want to edit the content of the file located in your hard disk, you can't do that with JS. Commented Aug 15, 2015 at 8:50
  • I am not sure what you want? I believe you should answer @Andrea reply... The question is not clear at all... Commented Aug 15, 2015 at 9:10
  • @Andrea yes this is my qustion Commented Aug 17, 2015 at 9:13

1 Answer 1

1

yes it is, take a look here https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild

// Create a new paragraph element, and append it to the end of the document body
var p = document.createElement("p");
document.getElementById("demo").appendChild(p);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.