d.toString(16)

Beautifully simple way to get a hex value from a number. Note that d is a number. If you want a string as a hex XML valid code, use:

'&#x' + parseInt(number).toString(16).toUpperCase() + ';'
Proudly sponsored by
CodeSponsor.io- get paid by adding one line of code to your README

Want more?

Posts, web development learnings & insights, exclusive workshop and training discounts and more, direct to your inbox.

I won't send you any spam, and you can unsubscribe at any time. Powered by ConvertKit