我想测试我的单选按钮文本是否等于“PayPal”。警告框显示“PayPal”,但显示或隐藏DIV内容的相等测试失败。
<%= radio_button_tag "order[payments_attributes][][payment_method_id]",
method.id, method == @order.available_payment_methods.first, data:
{behavior: "toggle-products"} %>
<div id="confirmpaypal" class="pull-right">
<%= button_tag "Continue" , type: 'submit',
class: 'btn btn-primary btn-small' do %>
"Confirm"
<% end %>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('input[type="radio"][data-behavior="toggle-products"]').click(function(evt) {
alert($(this).closest('label').text());
if($(this).closest('label').text() == "PayPal") {
$('#confirmpaypal').show();
} else {
$('#confirmpaypal').hide();
}
});
});
</script>