Following from my comment above, it might be better to manipulate the color in the HSL colorspace, so that you get bold colors. The trick is to maintain a constant luminance while randomising the hue and saturation.
For any combination of hue and saturation, 100% luminance will always be white and 0% luminance will always be black. The strongest impression of color will be seen with a luminance value right in the middle i.e. 50%.
You could do this as follows:
var h = Math.floor(Math.random() * 360); //hue is measured in degrees from 0-359
var s = Math.floor(Math.random() * 256); //saturation is a value from 0-255
$("#theElement").css("background-color","hsla(" + h + ", " + s + "%, 50%, 1)");
#theElement{
width: 100px;
height: 100px;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id=theElement></div>
So, say you want to generate a palette of 16 colors:
var colors = [];
for(var i = 0; i < 16; ++i)
{
var h = Math.floor(Math.random() * 360); //hue is measured in degrees from 0-359
var s = Math.floor(Math.random() * 256); //saturation is a value from 0-255
colors.push("hsla(" + h + ", " + s + "%, 50%, 1)");
}
var paletteIndex = 3; //for example
$("#theElement").css("background-color", colors[paletteIndex]);