money.js 라이브러리를 사용하여 작은 통화 변환 스크립트를 만드는 중이며 .append(); 부품. 여기에 지금까지 무엇을 가지고 :jQuery --append() not working
<script type="text/javascript">
$(document).ready(function() {
function pfxCurrencyConverter() {
//get the users options from the form and store in variables
var pfxFromCurrency = $('#pfx-from-currency').val();
var pfxToCurrency = $('#pfx-to-currency').val();
//set base options
fx.base = pfxFromCurrency
fx.settings = {
from: pfxFromCurrency
};
// get the amount input by the user
var inputAmount = $('#pfx-input-amount').val();
// Load exchange rates data via the cross-domain/AJAX proxy:
$.getJSON('http://openexchangerates.org/latest.json', function (data) {
// Check money.js has finished loading
if (typeof fx !== "undefined" && fx.rates) {
fx.rates = data.rates;
fx.base = data.base;
} else {
// If not, apply to fxSetup global:
var fxSetup = {
rates: data.rates,
base: data.base
}
}
var convertedValue = fx.convert(inputAmount, {to: pfxToCurrency});
$("#currencies").append("<li>New Value" + convertedValue + "</li>");
});
} //end pfxCurrencyConverter
$(document).ready(function() {
pfxCurrencyConverter();
});
</script>
</head>
<!-- output form for user to populate -->
<!-- Output the front end form, include external stylesheet and define customisable css -->
</head>
<!-- output form for user to populate -->
<body>
<form method="get" onsubmit="return pfxCurrencyConverter();">
Amount: <input type='text' id='pfx-input-amount' /><br />
From: <select id='pfx-from-currency'>
<option>Please Choose</option>
<option>GBP</option>
</select><br />
To: <select id='pfx-to-currency'>
<option>Please Choose</option>
<option>USD</option>
</select><br />
<input type='submit' value='Convert' />
</form>
<ul id="currencies"></ul>
</body>
</html>
내가 바로 전송 버튼 후 HTML에서이 있고, 그냥 문자열로 잘 작동하지만, 한 번 작동을 멈 춥니 다 나는 + convertedValue
<script>document.write("New Value" + convertedValue);</script>
를 추가 어떤 도움이라도 대단히 감사합니다.
? 선언 된 곳은 어디입니까? 또한 스크립트 태그는 "준비된"처리기 안에 있습니다. 실제로 코드가 어떻게 생겼습니까? 그대로 달릴 방법이 없습니다. – Pointy
또한 HTML5 문서에서 CDATA를 사용할 이유가 없습니다. – Pointy
감사합니다, Pointy, 편집 및 정리하지만 놈의 일은 아직 못해. – Danny