How to convert decimal to hexadecimal in JavaScript
问题 How do you convert decimal values to their hexadecimal equivalent in JavaScript? 回答1: Convert a number to a hexadecimal string with: hexString = yourNumber.toString(16); And reverse the process with: yourNumber = parseInt(hexString, 16); 回答2: If you need to handle things like bit fields or 32-bit colors, then you need to deal with signed numbers. The JavaScript function toString(16) will return a negative hexadecimal number which is usually not what you want. This function does some crazy