开发者

Problem facing parsing apostrophe in jquery.html()

开发者 https://www.devze.com 2023-01-16 02:26 出处:网络
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.. :-(

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;&amp;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); 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号