Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript random quote generator not printing
    text
    copied!<p>I'm trying to generate a fresh quote from a list on every refresh. For some reason, I can't get the quotes to show up within the div, and I'm not sure why.</p> <p>Any help would be greatly appreciated! </p> <pre><code>&lt;div id="quotes"&gt; &lt;script&gt; var quotes = new Array(); quotes[0] = "&lt;i&gt;Quote 1&lt;/i&gt;&lt;br&gt;&lt;b&gt;Author&lt;/b&gt;"; quotes[1] = "&lt;i&gt;Quote 2&lt;/i&gt;&lt;br&gt;&lt;b&gt;Author&lt;/b&gt;"; var random = Math.ceil (Math.random() * quotes.length) - 1; $('quotes').set('html', quotes[random]); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>I've updated my code thanks to everyones help to this-</p> <pre><code>&lt;div id="quotes"&gt;&lt;/div&gt; &lt;script&gt; var quotes = [ "&lt;i&gt;"Some people feel the rain. Others just get wet."&lt;/i&gt;&lt;br&gt;&lt;b&gt;Bob Marley/b&gt;", "&lt;i&gt;“Do not pray for an easy life, pray for the strength to endure a difficult one.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;Bruce Lee&lt;/b&gt;", "&lt;i&gt;“Success is not final, failure is not fatal: it is the courage to continue that counts.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;Winston Churchill&lt;/b&gt;", "&lt;i&gt;If your dreams don’t scare you they’re not big enough.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;“It takes courage to grow up and become who you really are.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;E.E. Cummings&lt;/b&gt;", "&lt;i&gt;All endings are also beginnings, we just don’t know it yet.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;There are three kinds of people: Those who make it happen, those who watch it happen, and those who wonder what the heck happened.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;There are people so poor, that the only thing they have is money.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;“Things do not happen. Things are made to happen.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;John F. Kennedy&lt;/b&gt;", "&lt;i&gt;“Destiny is a name often given in retrospect to choices that had dramatic consequences.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;J.K. Rowling&lt;/b&gt;", "&lt;i&gt;“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy’. They told me I didn’t understand the assignment, and I told them they didn’t understand life.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;John Lennon&lt;/b&gt;", "&lt;i&gt;“Not all those who wander are lost”&lt;/i&gt;&lt;br&gt;&lt;b&gt;JRR Tolkien&lt;/b&gt;", "&lt;i&gt;We all die. The goal isn’t to live forever, the goal is to create something that will.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;Strive for progress, not perfection.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;What defines us is how well we rise after falling.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;“It’s not hard to make decisions once you know what your values are.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;Roy E. Disney&lt;/b&gt;", "&lt;i&gt;Sorry’s not good enough.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;I may not be there yet, but I’m closer than I was yesterday. Every day is a new beginning. Stay away from what might have been and look at what can be.&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;Who inspires you?&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;", "&lt;i&gt;“If you play by the rules long enough, then you can change the game.”&lt;/i&gt;&lt;br&gt;&lt;b&gt;Enders Game&lt;/b&gt;" ]; document.getElementById('quotes').innerHTML = quotes[Math.floor(Math.random() * quotes.length)]; &lt;/script&gt; </code></pre> <p>For some reason, the div is still loading without any content thought.</p> <p>It was the quotes inside of my quotes messing it up. Thank you everyone for the help!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload