0

I want to replace a big section of html code (the content on the side) with other html code.

I have used the JavaScript code below:

document.getElementById("content").innerHTML = "";

The thing is that I can't replace html code that got the "" characters in it. Can someone please help me?

I should ad that I´m a beginner with JavaScript and as of now I want to stay away from jQuery.

1 Answer 1

2

try with

document.getElementById("content").innerHTML ='text to be replaced with "" ';

or with

document.getElementById("content").innerHTML ="text to be replaced with \"\"";

or with

document.getElementById("content").innerHTML ='text to be replaced with \'\'';

( \" is the escape sequence for the character " and in javascript you can use either ' or " for the strings)

here the jsfiddle sample

Sign up to request clarification or add additional context in comments.

1 Comment

Will be nice to mention that \" or \' are escape sequences. You cloud have a look at MDN.

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.