다음 코드에 문제가 있습니다. 단추를 클릭 할 때 배열에 임의의 문자열을 표시하려고합니다.쉬운 자바 스크립트 코드가 작동하지 않습니다.
<script>
var button = document.getElementById("button");
var div = document.getElementById("box");
var text = document.getElementById("text");
var array=[ "thanks for clicking", "keep on clicking", "click one more time", "why do you keep on clicking me?", "stop clicking me!"];
function thing(){
var y = array[Math.floor((Math.random() * array.length)+1)];
text.value=y;
}
function what(){
text.value = "what";
}
</script>
<body>
<form>
<input type="button" id="button" value="click" onClick="what()" />
</form>
<form>
<input type="text" id="text" value="hey" />
</form>
</body>
은 무엇 코드로 잘못? – showdev
thing()을 호출 할 때 '
아래로 스크립트를 이동하십시오. –