Have a look at below code block for the same.
Above line will return the a valid hex code for you.
Now suppose you want to change font color of any p tag then you just need to use below code. First of all give that tag any unique ID and have a look at below code block.
var color = '#'+Math.floor(Math.random()*16777215).toString(16);
$("highlight").setStyle('color', color )}
Have a look at this demo page which shows this trick in live mode.