텍스트 기반 HTML 게임을 만들려고합니다. jQuery에서 내 .append 메서드가 작동하지 않습니다. 내가 그것에 단락 태그를 append()하면 초를 표시하고 사라집니다. 도와주세요텍스트 기반 게임 코드가 작동하지 않습니까?
여기 내 코드입니다 :
<!DOCTYPE html>
<html>
<head>
<title>game</title>
<style>
</style>
</head>
<body>
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
/*var input;
var room;
function submitFunction() {
alert("hello")
}
*/
</script>
<script type="text/javascript">
var input;
var room;
room = "Main Enterence"
$(document).ready(function() {
$("#mainForm").submit(function() {
input = document.getElementById("textInput").value;
if (input == "east") {
if (room == "Main Enterence") {
room = "Bedroom"
enterBedroom();
}
}
if (input == "west") {
}
if (input == "north") {
}
if (input == "south") {
}
})
})
function enterBedroom() {
$("#consoleOutput").append("<p>Test</p>");
}
</script>
<div id="consoleOutput">
<p id="welcomeText"></p>
</div>
<form onsubmit="submitFunction()" id="mainForm">
<input type="text" id="textInput">
<input type="submit" name="sumbit">
</form>
</body>
</html>
안녕하세요, 텍스트 기반의 HTML 게임을 만들기 위해 노력하고 . jQuery에서 내 .append 메서드가 작동하지 않습니다. 내가 그것에 단락 태그를 append()하면 초를 표시하고 사라집니다. 제발 도와주세요
, 당신 또한 jquery submit 이벤트 핸들러를 사용한다면'onsubmit = "submitFunction()"'이 필요 없다. –