为什么我收到错误"错误:语法错误,无法识别的表达式:不支持的伪:选择"?

4 javascript jquery syntax-error

我遵循jQuery代码:

    $(document).ready(function() {
    $('.products').click(function () {
      var table_id = $(this).closest('table').attr('id');            
      var no = table_id.match(/\d+/)[0];            
      var first_row = $(this).closest('table').find('tbody tr:first').attr('id');    
      var new_row = $('#'+first_row).clone();
      var tbody = $('tbody', '#'+table_id);
      var n = $('tr', tbody).length  + 1;
      new_row.attr('id', 'reb' + no +'_'+ n);

      $(':input', new_row).not('.prod_list').remove();
      $(':select', new_row).attr('name','product_id_'+no+'['+n+']');
      $(':select', new_row).attr('id','product_id_'+no+'_'+n);
      $('<button style="color:#C00; opacity: 2;" type="button" class="close delete" data-dismiss="alert" aria-hidden="true">&times;</button>').appendTo( $(new_row.find('td:first')) );
      tbody.append(new_row);
      $('.delete').on('click', deleteRow);
     });
   });
Run Code Online (Sandbox Code Playgroud)

使用上面的代码,我在HTML表中添加了一个新的代码.但是这一行只包含select控件.所以我使用上面的代码将id和name的值设置为该选择控件.在此期间,我在firebug控制台中收到如下语法错误:

"Error: Syntax error, unrecognized expression: unsupported pseudo: select"
Run Code Online (Sandbox Code Playgroud)

如果我删除上面两行,我写了设置id和名称值来选择控件,其他代码工作绝对没有任何问题.那么有人可以解决这个问题并允许我设置新创建的行选择控件的id和值吗?谢谢

Aru*_*hny 12

没有选择器被调用:select,只是select(元素选择器)会做 - 你可能已经尝试过它因为伪选择器:输入是一个特殊的选择器,它将选择所有输入,选择和textarea元素

$('select', new_row)
Run Code Online (Sandbox Code Playgroud)