誰かがこの作業を手伝うことができるのだろうかと思います。私は毎日の見積もりのためのこの素晴らしいコードを見つけました、そして、私はちょうど日々の見積もりと見積もりの著者の間に改行を入れようとしています。多分2次元配列を作成する方が簡単だと思っていたのですが、残念ながら改行の仕方を理解できませんでした。ありがとうございました。ここでのコードは、これまでのところです:私はお勧めjavascript配列要素の間に改行を追加する
<script type="text/JavaScript">
var quote = new Array()
for (i=0; i<7; i++){
quote[i] = new Array(6)
}
quote[0][0] = 'If you want to go fast go alone, if you want to go far go together!';
quote[0][1] = 'African Proverb';
quote[1][0] = 'We either make ourselves happy or miserable. The amount of work is the same.';
quote[1][1] = 'Carlos Castaneda';
quote[2][0] = 'Everything should be made as simple as possible, but not any simpler.';
quote[2][1] = 'Albert Einstein';
quote[3][0] = 'Failure is the mother of success.';
quote[3][1] = 'Chinese Proverb';
quote[4][0] = 'The first to apologize is the bravest. The first to forgive is the strongest. The first to forget is the happiest.'
quote[4][1] = 'Unknown';
quote[5][0] = 'If an egg is broken by an outside force, life ends. If it is broken by an inside force life begins. Great things happen from the inside.';
quote[5][1] = 'Unknown';
quote[6][0] = 'Simplicity is the ultimate sophistication.'
quote[6][1] = 'Leonardo Da Vinci';
var qlen = quote.length;
var firstDate = new Date(2016,2,25);//start date (yyyy,m,d) - m=0=January, m=1=February
var today = new Date();//today
var dif = Math.floor((today-firstDate)/1000/60/60/24);//difference in days
while(dif>=qlen){//calculate the index of the quote of the day
dif=dif-qlen;//restart the array index if the difference is greater that the array's length
}
var todayQuote = quote[dif][0];//the quote of the day
var todayQuoteOwner = quote[dif][1];//author of the quote of the day
onload = function(){document.getElementById('q').firstChild.data = todayQuote + </n> + document.getElementById('qu').firstChild.data = todayQuoteOwner}
</script>
<div> id='q'; </div>
またはhtmlに出力する場合、 'document.getElementById( 'q')。firstChild.data = todayQuote +"
"+ document.getElementById( 'qu')。firstChild.data = todayQuoteOwner'? – Gogol
はありません。 –