我想将现有表单复制到另一个表单。我发现这个问题适用于正常输入,但它在我的复选框上引发错误
我正在使用的 jQuery 函数(from )是
(function($) {
$.fn.copyNamedTo = function(other) {
return this.each(function() {
$(':input[name]', this).each(function() {
$('[name=' + $(this).attr('name') +']', other).val($(this).val())
})
})
}
}(jQuery));
错误是:
Uncaught Error: Syntax error, unrecognized expression: [name=cartype[]]
复选框的排列方式如下:
<input type="checkbox" name="cartype[]" id="cartype_10" value="10">4x4
<input type="checkbox" name="cartype[]" id="cartype_11" value="11">Saloon
我希望这是由于[]
名称中的,但无法弄清楚该怎么做。