views:

66

answers:

1

I am stuck with a weird problem of parsing an aphostrophe. I cant use an escape character in "test" selector because this value is coming from the DB. How do i display this correctly.. :-(

Script is as follows

$(document).ready(function() {
var getVal = $('.test').text();
$('.newstest').html(getVal);
});

Html Code is as follows

<div class="test">&amp;apos;&amp;quot;</div><br /><br />
<div class="newstest"></div>

Thanks

A: 

Try this:

if($('.text').text().contains("\'"))
{
 //Do something here. Either replace the apostrophe with another character or display a   
 //default value.
}
else
{
 var getVal = $('.test').text(); 
 $('.newstest').html(getVal); 
}
Sidharth Panwar