How do you escape a colon in JavaScript? I've tried several fixes (backslashes, hexadecimal code) and no luck.

What is the context? Code needed.

I assume that you want to display the colon on the page instead of it being read as part of the code. In that case, use the HTML : to display it.

document.write('\'');
alert('\'')
Both works for me.

Post some of your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.