如何正确使用带按钮的jquery rails 4



我有两个单选按钮,当我点击text_field rails选择第一个单选按钮时,然后当我点击第二个单选按钮rails选择按钮时,当我再次点击text_field rails未选择所需按钮时,问题就开始了

<%= f.label "I will paid" %>
        <%= f.text_field :price %>  
        <%= f.radio_button :price, true %>
        <%= f.radio_button :price, false %>
        <%= f.label "let itself will offer price" %>
        <script>
        $(document).ready(function(){
          $('#post_price_false').click(function(){
            $('#post_price').val(''); 
          });
          $('#post_price').click(function(){
            $('#post_price_false').attr('checked',false);
            $('#post_price_true').attr('checked',true);
          });
          });</script>

有什么想法吗?

jquery中的所有问题,我为此重新编写了脚本:

$('#post_price').click(function(){
            $('#post_price_false').attr('checked',false);
            $('#post_price_true').attr('checked',true);

至:

$('#post_price').click(function(){
                $('#post_price_false').prop('checked',false);
                $('#post_price_true').prop('checked',true);

最新更新