I am new to JavaScript. I am trying to add text into a p tag and targeting it using the ID. Now, using the document.getElementById('text').innerHTML, when I set the text that contains the do word, it returns the original text in the p tag.
document.getElementById('text').innerHTML='as I add??? do';
<p id="text" class="abc">Hello</p>
It is happening only with the do word in between.
Here's a GIF explaining the issue:

I hope I am doing this right. But, there might be some quirk that is messing with me.
As commented by Juhana and jsbin member on github, it's a false positive, this can be achieved by adding // noprotect in the code.
e.g.
console.clear();
document.getElementById('abc').innerHTML = 'this is abc do ';
// noprotect
p.s. As of now it's to work around to loop protection, until it's get fixed.
When you use
document.getElementById("text").innerHTML = "abc a d";
They load this document (pretty formatted by me):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css"></style>
</head>
<body>
<p id="text">Hello</p>
<script>
try {
document.getElementById("text").innerHTML = "abc a d";
} catch (error) {
throw error;
}
//# sourceURL=wecinoqeje.js
</script>
</body>
</html>
But when you use do, they completely screw up your code.
document.getElementById("text").innerHTML = "abc a do";
They probably think it's a do-while, because they have something called "loop protection". The loaded document is
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css"></style>
</head>
<body>
<p id="text">Hello</p>
<script>
try {
{
;
window.runnerWindow.protect.protect({
line: 1,
reset: true
});
document.getElementById("text")
{
if (window.runnerWindow.protect.protect({ line: 1 }))
break;
.innerHTML = "abc a do";
}
}
} catch (error) {
throw error;
}
//# sourceURL=wecinoqeje.js
</script>
</body>
</html>
That's a syntax error. So your code does not run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With