You need to escape the string you are writing out into DoEdit to scrub out the double-quote characters. They are causing the onclick HTML attribute to close prematurely.

Using the JavaScript escape character, \, isn't sufficient in the HTML context. You need to replace the double-quote with the proper XML entity representation, ".

Answer from Aaron on Stack Overflow
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-escape-quotes-in-string
How to Escape Quotes in a String using JavaScript | bobbyhadz
March 2, 2024 - To escape a single or double quote in a string, use a backslash `\` character before each single or double quote in the contents of the string.
Discussions

I need help with escaping literal quotes
Tell us what’s happening: hey Your code so far var myStr = "I am a/'Double quoted\"string inside\"double quotes\"."; Your browser information: User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
June 19, 2019
Escaping Single and Double Quotes in a generated String - JavaScript - SitePoint Forums | Web Development & Design Community
Hi, I’ve been wrestling with this issue for a while and I’m hoping someone can help. I am building an administrative panel for one of my applications using ajax so I’m using lots of javascript to display information on the page. I’m having an issue with one piece in particular. More on sitepoint.com
🌐 sitepoint.com
0
April 23, 2006
Escaping Literal Quotes in Javascript - Stack Overflow
How do I have two quoted phrases in javascript. This is the challenge: I am a double quoted string inside double quotes. I have this: " I am a \"double quoted\" string inside "double quotes\"."; More on stackoverflow.com
🌐 stackoverflow.com
JavaScript - How escape quotes in a var to pass data through Json - Stack Overflow
I'm passing some data through Json to a Webservice. My problem is that i'm passing html (from a tinyMCE input), so the var has content using quotes and that's giving me problems. I'm passing the va... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › js › js_strings.asp
JavaScript Strings
4 weeks ago - Templates are strings enclosed ... will be chopped to "We are the so-called ". To solve this problem, you can use an backslash escape character....
🌐
Javascript-coder
javascript-coder.com › tricks › javascript-escape-double-quotes-in-string
How to escape double qoutes in a string | JavaScript Coder
If you just want to escape string literals, here are the ways to do it. There are at least three ways to create a string literal in Javascript - using single quotes, double quotes, or the backtick ( ).
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
I need help with escaping literal quotes - JavaScript - The freeCodeCamp Forum
June 19, 2019 - Tell us what’s happening: hey Your code so far var myStr = "I am a/'Double quoted\"string inside\"double quotes\"."; Your browser information: User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/…
🌐
javascript.com
javascript.com › learn › strings
JavaScript Strings: The Basic Methods and Functions | JavaScript.com
Alternatively, you can use a backslash \ to escape the quotation marks. This lets JavaScript know in advance that you want to use a special character. Here’s what that looks like reusing the examples above: Strings have their own built-in ...
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-work-with-strings-in-javascript
How To Work with Strings in JavaScript | DigitalOcean
August 24, 2021 - However, when we are working to use consistent syntax within project programming files, this can be difficult to maintain throughout a codebase. We can use the backslash (\) escape character to prevent JavaScript from interpreting a quote as the end of the string.
Find elsewhere
🌐
GitHub
github.com › EQuimper › CodeChallenge › blob › master › javascript › FreeCodeCamps › Basic JavaScript › Escaping Literal Quotes in Strings.md
CodeChallenge/javascript/FreeCodeCamps/Basic JavaScript/Escaping Literal Quotes in Strings.md at master · EQuimper/CodeChallenge
What happens when you need a literal quote: " or ' inside of your string? In JavaScript, you can escape a quote from considering it as an end of string quote by placing a backslash () in front of the quote.
Author   EQuimper
🌐
tutorialstonight
tutorialstonight.com › javascript-escape-quotes
JavaScript Escape Quotes (with Examples)
In this tutorial, you will learn how to escape quotes in JavaScript. To define a string in JavaScript we use single quotes (' ') or double quotes (" ").
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-use-escape-characters-to-correctly-log-quotes-in-a-string-using-javascript
How to use Escape Characters to Log Quotes in JavaScript? | GeeksforGeeks
September 9, 2024 - This approach allows you to print single quotes within the string seamlessly while maintaining correct syntax. Example: Using escape sequences - If you have begun the quotes using \' then you must end the quote also using \' and vice versa.
🌐
SitePoint
sitepoint.com › javascript
Escaping Single and Double Quotes in a generated String - JavaScript - SitePoint Forums | Web Development & Design Community
April 23, 2006 - Hi, I’ve been wrestling with this issue for a while and I’m hoping someone can help. I am building an administrative panel for one of my applications using ajax so I’m using lots of javascript to display information on…
🌐
Linux Hint
linuxhint.com › escape-a-single-quote-from-a-string-in-javascript
How to Escape a Single Quote From a String in JavaScript
June 3, 2023 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Rip Tutorial
riptutorial.com › escaping quotes
JavaScript Tutorial => Escaping quotes
var text = 'L\'albero means tree in Italian'; console.log( text ); \\ "L'albero means tree in Italian" ... Special attention must be given to escaping quotes if you're storing HTML representations within a String, since HTML strings make large use of quotations i.e.
🌐
EyeHunts
tutorial.eyehunts.com › home › javascript escape a single quote in a string variable | example code
JavaScript escape a single quote in a string variable | Example code
June 24, 2021 - Using Regex and replace method will escape single quote in string variable in JavaScript. Let's see simple HTML example cdoe
🌐
EyeHunts
tutorial.eyehunts.com › home › javascript escape quotes in a string | example code
JavaScript escape quotes in a string | Example code
April 20, 2022 - You will need to use regular expression to escape quotes in a string in JavaScript. HTML example code for single and double quote...
🌐
Tutorial Reference
tutorialreference.com › javascript › examples › faq › javascript-how-to-escape-quotes-in-string
How to Escape Quotes in a String in JavaScript | Tutorial Reference
When defining a string literal, ... need to programmatically escape a string that is already in a variable, use the replaceAll() method to replace all instances of a quote with its escaped version....