Definition: To insert ('') single quote in JavaScript, use ( \ ) backslash.
The backslash ( \ ) is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
Example:
Script Part:
<script type="text/javascript" language="javascript">
function show()
{
var text ="how to use \'single quote\'";
document.getElementById("txtSpecial").value = text;
}
</script>
HTML Control:
<input value="" id="txtSpecial" name="txtSpecial" type="text"/><br />
<input type="submit" name="show" id="show" value="Special Character" onclick="show();"/>
The backslash ( \ ) is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
Example:
Script Part:
<script type="text/javascript" language="javascript">
function show()
{
var text ="how to use \'single quote\'";
document.getElementById("txtSpecial").value = text;
}
</script>
HTML Control:
<input value="" id="txtSpecial" name="txtSpecial" type="text"/><br />
<input type="submit" name="show" id="show" value="Special Character" onclick="show();"/>
Output:
how to use 'single quote'
• Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online Training course
ReplyDelete