I need help with a script that changes the color of each character in an element ("logo p") to a random color when hovered over. How can I modify this script to run automatically on page load, so that all characters have random colors at all times?
$(document).ready(function() {
// COLOURS ARRAY
var colours = Array("#B0171F", "#FF3E96", "#FF00FF", "#8B008B", "#9400D3", "#BF3EFF", "#B22222", "#FF0000", "#800000", "#8E388E", "#bc8f8f"), idx;
$("#logo p").hover(function(){
var header = $(this);
var characters = header.text().split('');
header.empty();
var content = '';
for(var i = 0; i < characters.length; i++) {
idx = Math.floor(Math.random() * colours.length);
content += '<span style="color:'+colours[idx]+'">' + characters[i] + '</span>';
}
header.append(content);
}, function() {
$(this).find('span').contents().unwrap();
});
});