キーワードのリストをシャッフルして、テキスト スライドショー内の個々の div に入れようとしています。
これが私のスクリプトです:
var keys = ["dancing.", "computers.", "food.", "movies.", "singing.", "hiking.", "math.", "music.", "reading.", "cars.", "laughing.", "animals.", "cupcakes.", "shopping.", "soccer.", "Europe.", "photography.", "volunteering.", "outerspace.", "traveling.", "guitar.", "painting.", "children.", "boats.", "science.", "art.", "cheerleading.", "Einstein.", "teaching.", "politics.", "waterskiing.", "volleyball.", "whittling.", "volleyball.", "running.", "comedy.", "theater.", "Africa."];
keys.sort(function() { return Math.floor(Math.random()*3 -1)});
for(i = 0; i < keys.length; i++) {
("<div>" + keys[i] + "</div>").appendTo("slideshow");
}
function randomize(myArray) {
var i = myArray.length;
if ( i == 0 ) return false;
while ( --i ) {
var j = Math.floor( Math.random() * ( i + 1 ) );
var tempi = myArray[i];
var tempj = myArray[j];
myArray[i] = tempj;
myArray[j] = tempi;
}
}
<td class="align-top">
<div class="slideshow"></div>
</td>
何か案は?また、javascript と jQuery の組み合わせが悪いと思います。これをきれいにするのを手伝ってくれませんか?