【发布时间】:2014-10-20 02:35:03
【问题描述】:
我有一个结帐表格,它适用于除 IE8 之外的所有应用程序。 我正在更改它以使用 ajax 将输入结果保存为会话数据。 当我使用第一个“点击”功能时,一切都很好,但我无法触发“提交”功能(没有警报)。以下显示/隐藏正在工作。 请让我另眼相看。
表格
<form name="payment_method_form" id="payment_method_form" method="post">
<div class="pay_method">
<input type="radio" name="pay_method" value="cc"> Credit Card
</div>
<div class="pay_method">
<input type="radio" name="pay_method" value="pp"> Paypal
</div>
<div class="pay_method">
<input type="radio" name="pay_method" value="dd"> Direct Deposit
</div>
<div class="pay_method">
<input type="radio" name="pay_method" value="cash"> Cash on Delivery
</div>
</form>
脚本(包含在 $(document).ready() 中)
$('input[name$="pay_method"]').click(function() {
$('#payment_method_form').submit(function(e) {
alert("clicked")
<!-- ajax here -->
});
var pay_method = $(this).val();
$('.pay_option').hide();
$("#"+pay_method).show();
});
【问题讨论】:
标签: jquery ajax radio-button form-submit