jQuery Escape Single Quote in String / JavaScript Show Single Quote in String

Introduction

Here I will explain how to use jQuery to escape single quote in string or show single quote in string using JavaScript.

Description:


jQuery Show Single Quote in String

To show string with single quote we need to write the code as shown below

<script type="text/javascript">
$(function() {
$('#lbltxt').text('Today\'s Data');
})
</script>
If you want to see it in complete example check below code

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Show Single Quote in String</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$('#lbltxt').text('Today\'s Data');
})
</script>
</head>
<body>
<div>
<label id="lbltxt" />
</div>
</body>
</html>

Comments

Post a Comment