$(function() {
convertPrice = function() {
var myAnswer, myVal, myRate;
myVal = $('#slider1').val();
myRate = $('#rate').val();
myVal = parseFloat(myVal); // convert string type
myAnswer = myVal * myRate;
$('#Answer').val(myAnswer);
}
$("#convertButton").click(convertPrice);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div data-role="fieldcontain">
<label for="R">Cost Per Person:</label>
<input type="text" value="$990" name="rate" id="rate" readonly />
</div>
<label for="slider">Number of People Going?:</label>
<input type="range" name="slider" id="slider1" value="1" min="1" max="30" />
</div>
<input type="button" value="Convert" id="convertButton" />
<div data-role="fieldcontain">
<label for="theAnswer">Results:</label>
<input type="text" name="textInput" id="Answer" value="" readonly />
</div>
所以,當我按一下按鈕,它只是返回的喃?有什麼建議麼?
非常感謝!它總是那麼小,我想念。 –