I want to check if selected element contains n-dash only:
<p>–</p>
But jQuery does not compare it this way:
$('p').text()=="-"
$('p').html()=="-"
$('p').text()=="–"
$('p').html()=="–"
All above is false.
CodePudding user response:
https://api.jquery.com/contains-selector/
https://www.fileformat.info/info/unicode/category/Pd/list.htm
let selector = $('p:contains("\u2013")');
if (selector.length) {
console.log('got it !');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>–</p>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>