我試圖進行一個腳本,我想工作如下:每次的Javascript:這個詞被點擊5次時,一個字顯示在下面
一句話顯示出來,並在用戶點擊句子,另一句話出現。有五個句子選項,每次用戶點擊一個「隨機」句子顯示的句子。然後點擊5次後,出現下面的鏈接。我希望這一切都是一個容器/格的分開。
這裏是我的代碼
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<style>
#container{
background: #eeeeee;
width:330px;
height:220px;
margin-top:350px;
margin-left:700px;
border:1px solid #000000;
border-top: 5px solid #000000;
border-top-left-radius:.5em;
border-top-right-radius:.5em;
opacity: .7;
text-align: center;
z-index:4;
position: fixed;
box-shadow: 8px 8px 2px;
overflow: hidden;
font-family: 'Courier New', Courier, monospace;
}
a:link {color:#0000e6; background-color:transparent}
</style>
</head>
<body>
<div id="container"> </div>
<script>
var container=["random sentence1", "random sentence2", "random sentence3", "random sentence4", "random sentence5", "random sentence6"];
function dieroll() {
var chance=Math.floor(Math.random()* container.length);
var roll=document.getElementById("container");
roll.innerHTML= container[chance];
roll.style.fontSize="8px";
roll.style.cursor="pointer";
}
var text1 =document.createElement('div');
text1.innerHTML = '<a href="#">the link that would show up beneath the random sentences above';
text1.style.padding ="10px";
text1.style.display ="none";
console.log("array at:"+i);
var numClicks = 0;
var x = 5;
if (numClicks == x) {
con.innerHTML+=list[i];
i++;
} else {
con.appendChild(text1);
$(text1).fadeIn(3000);
//console.log(chance)
window.onload=function(){
dieroll();
};
</script>
</body>
</html>
您可以跟蹤點擊事件中的點擊次數,然後在第五次點擊或甚至點擊時做一些特殊的事情,將它們均勻地分成5次。 – lintmouse 2015-03-30 20:33:53
您遇到的問題是......? – j08691 2015-03-30 20:34:05