Pick next function
<p>My "#picknext" function picks the next word in the grid to spell for the user. At the moment it does its job apart from when it chooses the same row twice in a row.</p>

<p>How can I prevent this?</p>

<pre><code>$('#pickNext').mousedown(function() {
    // remove the class from all td's
    $('td').removeClass('spellword');
    // pick a random word
    rndWord = Math.floor(Math.random() * (listOfWords.length));

    // apply class to all cells containing a letter from that word
    $('td[data-word="' + listOfWords[rndWord].name + '"]').addClass('spellword');
});
</code></pre>

<p>HTML...</p>

<pre><code>&lt;ul style="display:none;" id="wordlist"&gt;
  &lt;li data-word="mum" data-audio="http://www.wav-sounds.com/cartoon/daffyduck1.wav" data-pic="http://www.clker.com/cliparts/5/e/7/f/1195445022768793934Gerald_G_Lady_Face_Cartoon_1.svg.med.png"&gt;&lt;/li&gt;
  &lt;li data-word="cat" data-audio="http://www.wav-sounds.com/cartoon/porkypig1.wav" data-pic="http://www.clker.com/cliparts/c/9/9/5/119543969236915703Gerald_G_Cartoon_Cat_Face.svg.med.png"&gt;&lt;/li&gt;
  &lt;li data-word="dog" data-audio="http://www.wav-sounds.com/cartoon/porkypig1.wav" data-pic="http://www.clker.com/cliparts/e/9/4/1/1195440435939167766Gerald_G_Dog_Face_Cartoon_-_World_Label_1.svg.med.png"&gt;&lt;/li&gt;
  &lt;li data-word="bug" data-audio="http://www.wav-sounds.com/cartoon/porkypig1.wav" data-pic="http://www.clker.com/cliparts/4/b/4/2/1216180545881311858laurent_scarabe.svg.med.png"&gt;&lt;/li&gt;
  &lt;li data-word="rat" data-audio="http://www.wav-sounds.com/cartoon/daffyduck1.wav" data-pic="http://www.clker.com/cliparts/C/j/X/e/k/D/mouse-md.png"&gt;&lt;/li&gt;
  &lt;li data-word="dad" data-audio="http://www.wav-sounds.com/cartoon/daffyduck1.wav" data-pic="http://www.clker.com/cliparts/H/I/n/C/p/Z/bald-man-face-with-a-mustache-md.png"&gt;&lt;/li&gt;
</code></pre>

<p></p>
