我确信这是一个简单的问题。我有一些随机化引号的javascript,但我希望引用和引用的作者是不同的颜色。我当然可以使用 CSS 来更改所有文本的外观,但是我没有太多运气将引用和作者分开,而且我对 javascript 也不是很精通。
<script language="JavaScript">
var Quotation=new Array()
Quotation[0] = "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.<br>Albert Einstein";
Quotation[1] = "Science is a way of thinking much more than it is a body of knowledge. <br>Carl Sagan";
Quotation[2] = "Few tragedies can be more extensive than the stunting of life, few injustices deeper than the denial of an opportunity to strive or even to hope, by a limit imposed from without, but falsely identified as lying within.<br>Stephen Jay Gould";
Quotation[3] = "I don't want to talk to you no more, you empty-headed animal food trough wiper! I fart in your general direction! Your mother was a hamster and your father smelt of elderberries!<br>Taunting Frenchman";
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>