jQuery special characters causing issues -
i have simple script looking heading perform function when heading matched. running issues special characters copyright , registered trademarks.
var isdisclosure = $('.disclosure-container h3').html(); if ( isdisclosure == "awesome product<sup>®</sup> disclosures" ) { alert('zomg'); }
the html looks in firebug:
<h3 class="inline"> awesome product <sup>®</sup> disclosures </h3>
upon viewing source html looks this...
<h3 class="inline">awesome product<sup>®</sup> disclosures</h3>
so when add html if statement, added character , doesn't work... so...
if ( isdisclosure == "awesome product<sup>©</sup> disclosures" )
i open searching "awesome product" wildcard or @ end.
you use regex test partial match
if(/awesome\sproduct<sup>.+</sup>\sdisclosures/i.test(isdisclosure))
or index of
if(isdisclosure.indexof("awesome product") >= 0)
or reference html hidden div.
<div id="refs" style="display:none;"> <h3 id="awesome"> awesome product <sup>®</sup> disclosures </h3> </div> if(isdisclosure == $("#refs #awesome").html())
Comments
Post a Comment