0
필자가 작성하려고하는이 돈 관리 시스템이 있는데 제대로 작동하지 않습니다. 돈은 오른쪽 상단에 인쇄되어 있지만 버튼을 클릭하여 값을 변경하면 작동하지 않습니다.Javascript onClick 함수가 작동하지 않습니다.
HTML :
<div id="content">
<div id="money_count">$$MONEY$$</div>
<br>
<div id="items">
<table>
<tr>
<td><a href="#">$12.19</a>
</td>
<td><a href="#">$15.00</a>
</td>
</tr>
<tr>
<td><a href="#">$24.99</a>
</td>
<td><a href="#">$35.50</a>
</td>
</tr>
</table>
</div>
</div>
CSS :
#content {
font-family:Helvetica;
width:500px;
box-shadow:0px 0px 10px 0px #AAA;
top:30px;
margin:0px auto;
margin-top:40px;
padding:10px 20px;
border:dashed 2px #888;
}
#money_count {
color:#0F0;
padding:5px;
text-shadow:0px 0px 1px #333;
margin-right:0;
margin-left:auto;
margin-top:6px;
width:100px;
text-align:center;
}
table, th td {
border:ridge 3px #AAA;
box-shadow:0px 0px 6px 0px #AAA;
}
table {
width:400px;
margin-left:50px;
margin-top:20px;
margin-bottom:50px;
}
td {
padding:4px;
background-color:#CCC;
text-align:center;
}
a, td {
color:black;
text-decoration:none;
width:auto;
height:100px;
}
자바 스크립트 :이 오른쪽 상단에있는 돈 값을 업데이트하지 않는 이유에
var money = 500.27 - 0.27;
var moneyElement = document.getElementById("money_count");
moneyElement.innerHTML = money;
function updateMoney() {
moneyElement.innerHTML = money;
}
function subtractMoney(amount) {
money -= amount;
updateMoney();
}
어떤 아이디어?
경우 onclick 이벤트는? – visnu
코드에 onclick 이벤트가 포함되어 있지 않습니다. –
제쳐두고, Javascript floats를 돈 값으로 사용하면 안됩니다. 어쩌면 이것이 도움이 될 수 있습니다 - http://josscrowcroft.github.io/accounting.js/. –