Problem facing parsing apostrophe in jquery.html()
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">&开发者_如何学JAVA;amp;apos;&quot;</div><br /><br />
<div class="newstest"></div>
Thanks
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);
}
精彩评论