我有如下功能
$(document).ready(function() {
$("#payment-form").submit(function(event) {
// disable the submit button to prevent repeated clicks
$('.submit-button').attr("disabled", "disabled");
// createToken returns immediately - the supplied callback submits the form if there are no errors
Stripe.createToken({
name: $('.card-name').val(),
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
}, stripeResponseHandler);
return false; // submit from callback
});
});
if (window.location.protocol === 'file:') {
alert("stripe.js does not work when included in pages served over file:// URLs. Try serving this page over a webserver. Contact support@stripe.com if you need assistance.");
}
我还有一个包含输入的表单如下:
<input type="text" size="2" class="card-expiry-month" /> <span>/</span>
我可以获得卡片到期月份的价值,但是当我尝试将其更改为下拉表格时,不会提交
<select id="expiration-month" class ="card-expiry-month"
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
答案 0 :(得分:-1)
尝试
$('#expiration-month:selected')。val();
<script type="text/javascript">
$(function () {
$("#clickable").click(function() {
alert($('#expiration-month :selected').val());
});
});
</script>
<div id='clickable'> Click Me </div>
<select id="expiration-month" class ="card-expiry-month">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>