nayen — 2014-07-18T03:34:59-04:00 — #1
I was wondering if what I am trying to do is possible. I have a string variable and I need to put HTML comment in it like this:
var text = 'Some text. <!-- comment --> Some more text.';
The above code doesn't work, is there any way to do this?
rlm2008 — 2014-07-18T07:12:15-04:00 — #2
Something like this?
var text = "Some text. <!-- comment --> Some more text.",
myDiv = document.getElementById('myDiv');
myDiv.innerText = text;
wolfshade — 2014-07-18T08:44:33-04:00 — #3
I'm curious as to whether that will actually hide the commented value, or will it also print out the <!-- [value] -->, as well?
nayen — 2014-07-18T09:01:49-04:00 — #4
Sorry, my bad. The code I have actually works. It looked like it didn't because of the color styling my text editor has. Thanks for your input on the topic.
wolfshade — 2014-07-18T09:12:58-04:00 — #5
Hot diggity. Never, ever, once thought about putting a comment within a string. Figured that because it's a literal, then the HTML wouldn't process <!-- and --> as code, rather it would as a string. Just played around with it. Very interesting.