I think you're using less-well-supported Unicode values, which don't always have glyphs for all the code points.
Try the following characters:
- โ (0x2610 in Unicode hexadecimal [HTML decimal:
☐]): an empty (unchecked) checkbox - (0x2611 [HTML decimal:
☑]): the checked version of the previous checkbox - โ (0x2713 [HTML decimal:
✓]) - (0x2714 [HTML decimal:
✔])
Edit: There seems to be some confusion about the first symbol here, โ / 0x2610. This is an empty (unchecked) checkbox, so if you see a box, that's the way it's supposed to look. It's the counterpart to / 0x2611, which is the checked version.
Answer from John Feminella on Stack OverflowI think you're using less-well-supported Unicode values, which don't always have glyphs for all the code points.
Try the following characters:
- โ (0x2610 in Unicode hexadecimal [HTML decimal:
☐]): an empty (unchecked) checkbox - (0x2611 [HTML decimal:
☑]): the checked version of the previous checkbox - โ (0x2713 [HTML decimal:
✓]) - (0x2714 [HTML decimal:
✔])
Edit: There seems to be some confusion about the first symbol here, โ / 0x2610. This is an empty (unchecked) checkbox, so if you see a box, that's the way it's supposed to look. It's the counterpart to / 0x2611, which is the checked version.
First off, you should realize that you don't actually need to use HTML entities โ as long as your HTML document's encoding is declared properly as UTF-8, you can simply copy/paste these symbols into your file/server-side script/JavaScript/whatever.
Having said that, here's the exhaustive list of all relevant UTF-8 characters / HTML entities related to this topic:
- โ (hex:
☐/ dec:☐): ballot box (empty, that's how it's supposed to be) - (hex:
☑/ dec:☑): ballot box with check - โ (hex:
☒/ dec:☒): ballot box with x - โ (hex:
✓/ dec:✓): check mark, equivalent to✓and✓in most browsers - (hex:
✔/ dec:✔): heavy check mark - โ (hex:
✗/ dec:✗): ballot x - โ (hex:
✘/ dec:✘): heavy ballot x - ๐ธ ( hex:
🗸/ dec🗸): light check mark (poorly supported as of 2017) - ( hex:
✅/ dec:✅): white heavy check mark (mixed support as of 2017) - ๐ด ( hex:
🗴/ dec:🗴): ballot script X (poorly supported as of 2017) - ๐ถ ( hex:
🗶/ dec:🗶): ballot bold script X (poorly supported as of 2017) - โฎฝ ( hex:
⮽/ dec:⮽): ballot box with light X (poorly supported as of 2017) - ๐ต ( hex:
🗵/ dec:🗵): ballot box with script X (poorly supported as of 2017) - ๐น ( hex:
🗹/ dec:🗹): ballot box with bold check (poorly supported as of 2017) - ๐ท ( hex:
🗷/ dec:🗷): ballot box with bold script X (poorly supported as of 2017)
Checking out web fonts for tick symbols? Here's a ready to use sample for the more common ones: AโBCโDโEFโGโH -- just copy/paste this into your webfont provider's sample text box and see which fonts support what tick symbols.
Check it with typeof:
typeof x === 'symbol'
Updated 2022: Go with the accepted answer! If you're working in an environment so outdated that Symbol needs to be polyfilled, then you'll know that already. You'll be excruciatingly aware of it. You'll be haunted by it. Then, sure, use my answer. Otherwise don't bother. typeof x === 'symbol' is almost definitely all you need these days.
In ES 2015 and up, typeof x === 'symbol' is all that's needed. But it won't work if you're transpiling your code to ES 5.1 or earlier, even if you're using a polyfill for the Symbol builtin.
Every polyfill I've seen, including the babel-polyfill, implements Symbol as an object (i.e. typeof x === 'object') using a constructor function called Symbol. So in those cases you can check that Object.prototype.toString.call (x) === '[object Symbol]'*.
Putting it all together, then, we get:
function isSymbol (x) {
return typeof x === 'symbol'
|| typeof x === 'object' && Object.prototype.toString.call (x) === '[object Symbol]';
}
*Note that I'm not using instanceof in the transpiled scenario. The problem with instanceof is that it only returns true for objects that were created within the same global context as the assertion being made. So if, say, a web worker passes a symbol back to your page, or symbols are passed between iframes, then x instanceof Symbol will return false! This has always been true of all object types, including the builtins. instanceof often works just fine, but if there's any chance of your code being in a "multi-frame" scenario as I've described, use with caution!
If you don't want to use the other answer that make a direct symbol condition $("#xxx").text() == "โธ" and you want to check the span text ▸, you could use .charCodeAt(0) to get the special symbole number then add &# and ; in your condition :
var special_symbol_number = $("#xxx").text().charCodeAt(0);
if ( "&#"+special_symbol_number+";" === "▸")
alert("hello");
Or you could check just with special symbol number as :
if ($("#xxx").text().charCodeAt(0) === '9656')
alert("hello");
Hopet this helps.
if ($("#xxx").text().charCodeAt(0) === '9656')
alert("hello");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="xxx">9656</span>
because ▸ is actually this character โธ
When you do $('#xxx').text() you'll get โธ
Try doing it this way:
if ($("#xxx").text() == "โธ")
alert("hello");
From looking at the other questions linked in this one. Looks like the way to do what you're looking for is:
if ($("#xxx").text().charCodeAt() == '9656')
alert("hello");