0
所以基本上我試圖做到這一點,所以當我點擊一個或一個它會將我的圖像移動到不同的位置。我純粹從代碼片斷中編寫代碼,我在互聯網上找到了代碼,我可能做了一些非常錯誤的事情。我不能通過點擊「a」來移動我的圖像
function move1() {
document.getElementById("character").style.right=450px;
}
var KeypressFunctions = [];
KeypressFunctions['A'.charCodeAt(0)] = move1
KeypressFunctions['a'.charCodeAt(0)] = move1
h1 {
width: 300px;
margin:400px auto;
color: red;
font-family:Impact ;
}
#character {
width:45px;
height:45px;
position:fixed;
bottom:100px;
right:800px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="mainc.css">
<script src="javascript.js"></script>
</head>
<body>
<h1>
So I am just testing out stuff on here
</h1>
<img src="C:/Users/Nick Malone/Desktop/Downloads/block.jpg" id="character">
</body>
</html>
你有沒有嘗試設置使用權 –
我還沒有試過尚未阿希什,到底我怎麼做這個的保證金insted的? – nick
只需使用'''document.getElementById(「character」)。style.marginRight = 450px;''' –