My page is a jsp page, which contains a parameter: lefttree, This lefttree is spelled out from the background, and the content is html code: such as: Copy code The code is as follows: In the jsp page, this value needs to be paid to a div through js code, as follows: Copy code The code is as follows: <br>window.parent.document.getElementById('mptree').innerHTML='<%=lefttree %>'; <br><script> <br> </div> <br>In this way, since lefttree contains both single quotes and double quotes, it matches the outermost single quote when assigning values in js The error becomes: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="2658" class="copybut" id="copybut2658" onclick="doCopy('code2658')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code2658"> <br>'<div class= "test" onclick="show('tt1','abc')">' <br> </div> <br>Solution: <br><br>Use the escape character "/" <br><br>When splicing lefttree in the background, it becomes the following form: <br><br><div class="codetitle"> <span><a style="CURSOR: pointer" data="42179" class="copybut" id="copybut42179" onclick="doCopy('code42179')"><u>Copy the code </u></a></span> The code is as follows: </div> <div class="codebody" id="code42179"> <br><div class="test" onclick="show(///'tt1///',///'abc///')"> <br> </div> <br>Where: <br><br>The first two "//" are used to keep the next "/" in the page <br><br>The third "/" is used to escape the following single quote. <br><br>In this way, in the web page, the value of lefttree is: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="23616" class="copybut" id="copybut23616" onclick="doCopy('code23616')"><u>Copy the code</u></a></span> The code is as follows:</div> <div class="codebody" id="code23616"> <br><div class="test" onclick="show(/'tt1/',/'abc/')"> <br> </div>